hanatharesh2712 / ionic-native-sms-retriever-plugin-master

Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
27 stars 18 forks source link

How to use with ionic 3 typescript? #9

Closed prescindivel closed 4 years ago

prescindivel commented 4 years ago

I'm getting the following error:

'SmsRetriever' refers to a value, but is being used as a type here.

My component:

...
...
import { SmsRetriever } from '@ionic-native/sms-retriever';

@IonicPage()
@Component({
  selector: 'page-token-modal',
  templateUrl: 'token-modal.html'
})
export class TokenModalPage {
...
...
constructor(
    ...
    private smsRetriever: SmsRetriever,
  ) {
   ...
  }
}
prescindivel commented 4 years ago

I changed the import path to import { SmsRetriever } from '@ionic-native/sms-retriever/ngx'; and it worked, but now I get another error:

when I invoke this.smsRetriever.startWatching()

Uncaught (in promise): TypeError: Object(...) is not a function
hanatharesh2712 commented 4 years ago

Seems you haven’t installed the plugin or may not installed properly. You can install the plugin and node module using below commands:

ionic cordova plugin add cordova-plugin-sms-retriever-manager@latest

npm install @ionic-native/sms-retriever

and make sure you are calling plugin method are device ready.

and Thanks for the know to change the import path to import { SmsRetriever } from '@ionic-native/sms-retriever/ngx'; I have changed in the documentation. Thanks!

hanatharesh2712 commented 4 years ago

Thanks for helping!

guillem-sopra commented 4 years ago

This is still happening to me, after doing this https://github.com/hanatharesh2712/ionic-native-sms-retriever-plugin-master/issues/9#issuecomment-524196891

I have tried everything: deleting node_modules, plugins and platforms, and alyaws the same:

TypeError: Object(...) is not a function
    at SmsRetriever.getAppHash (vendor.js:107565)

  ...
hanatharesh2712 commented 4 years ago

@guillem-sopra Can you share your ionic info? and installed plugins list

hanatharesh2712 commented 4 years ago

@guillem-sopra You find working demo here: https://github.com/hanatharesh2712/sms-plugin-test

guillem-sopra commented 4 years ago

Thanks a lot @hanatharesh2712 but that is Ionic 4 right? Do you have by any chance any working example with Ionic 3 and TS?

hanatharesh2712 commented 4 years ago

@guillem-sopra You find working demo for Ionic 3 here: https://github.com/hanatharesh2712/sms-plugin-test-ionic-3

See this file: https://github.com/hanatharesh2712/ionic-native-sms-retriever-plugin-master/issues/11#issuecomment-568655748

guillem-sopra commented 4 years ago

Thanks man. I see that it works, I'm going to try to implement this on my project