Closed payalkaur closed 5 years ago
Are you calling a function(retriveSMS) before device ready event?
I was not calling the function in platform ready before. After reading your comment I called the function inside it but still getting the same error.
Can you post your code sample here? and one more thing is, Which devices or emulators are you using for test this? THIS WON'T WORK IN WEB BROWSER e.g. using ionic serve[command]
Yes I know it doesn't work on serve I am trying it on OnePlus 6
home.ts :
`import { Component } from '@angular/core'; import { NavController, Platform } from 'ionic-angular'; import { HTTP } from '@ionic-native/http';
@Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { mobnumber: number; otp: number;
constructor(public navCtrl: NavController, public http: HTTP, public platform: Platform) { }
retrieveSMS() { this.platform.ready().then(() => { var headers = { "Access-Control-Allow-Origin": "*", "Accept": "application/json", "content-type": "application/json", "Access-Control-Allow-Methods": "POST, GET, OPTIONS, PUT" };
let data1 = {
mobnumber: this.mobnumber,
};
this.http.post('SMSRetrieverAPIURL', data1, headers)
.then(data => {
(<any>window).cordova && (<any>window).cordova.plugin && (<any>window).cordova.plugin.smsretriever && (<any>window).cordova.plugin.smsretriever.startWatching(
// the first callback is the success callback. We got back the native code’s result here.
(result) => {
alert('Message ' + result);
},
// the second is the error callback where we get back the errors
(err) => {
alert('Error ' + err);
}
);
})
.catch(error => {
});
})
} }`
@payalkaur You are accessing the wrong variable. It should be 'window.cordova.plugins
'. and you have typed as '(<any>window).cordova.plugin.smsretriever
'
I would suggest please try below code and put outside of your callback function:
window['cordova']['plugins']['smsRetriever']['startWatching'](
// the first callback is the success callback. We got back the native code’s result here.
(result) => {
console.log('Message', result);
},
// the second is the error callback where we get back the errors
(err) => {
console.log(err);
}
);
You can debug this issue using chrome inspect tools. and you will have more idea. Thanks
I changed it to (<any>window).cordova.plugin.smsretriever
because window.cordova.plugins
was giving plugin error.
After using the above code I was getting TIMEOUT error. I got the solution in https://github.com/hanatharesh2712/ionic-native-sms-retriever-plugin-master/issues/3
It is working now.
Thank you.
You are welcome! closing this issue.
Hi @hanatharesh2712 , The plugin was working fine in a different project but now when I am trying to integrate it in my actual app, it is giving me Google service version conflict error. I think it is conflicting with FCM plugin. I tried few things but nothing worked.
Here is my plugin list -
com.darktalker.cordova.screenshot 0.1.5 "Screenshot" cordova-plugin-advanced-http 2.0.2 "Advanced HTTP plugin" cordova-plugin-android-permissions 1.0.0 "Permissions" cordova-plugin-camera 4.0.3 "Camera" cordova-plugin-camera-preview 0.10.0 "cordova-plugin-camera-preview" cordova-plugin-crop 0.3.1 "CropPlugin" cordova-plugin-device 2.0.2 "Device" cordova-plugin-facebook4 4.1.0 "Facebook Connect" cordova-plugin-fcm-with-dependecy-updated 2.3.0 "Cordova FCM Push Plugin" cordova-plugin-file 6.0.1 "File" cordova-plugin-file-opener2 2.0.19 "File Opener2" cordova-plugin-file-transfer 1.7.1 "File Transfer" cordova-plugin-fullscreen 1.1.0 "cordova-plugin-fullscreen" cordova-plugin-geolocation 4.0.2-dev "Geolocation" cordova-plugin-inappbrowser 3.0.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 2.1.4 "cordova-plugin-ionic-webview" cordova-plugin-nativegeocoder 3.1.2 "NativeGeocoder" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-printer 0.7.3 "Printer" cordova-plugin-screen-orientation 3.0.1 "Screen Orientation" cordova-plugin-sms-retriever-manager 0.0.2 "Device" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-telerik-imagepicker 2.2.2 "ImagePicker" cordova-plugin-transfer 1.0.4 "cordova plugin pause resume download file" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-x-socialsharing 5.4.1 "SocialSharing" es6-promise-plugin 4.2.2 "Promise" ionic-plugin-deeplinks 1.0.17 "Ionic Deeplink Plugin"
And below is the error I am getting -
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.+.
Can you reopen this issue? Looking forward for your reply. Thanks
@payalkaur You may be using some other plugins which use google play services. so, make sure that all plugins are using the same version of google play services.
You can see in you config.xml file, In which this plugin default use play services version 15.0.1
<plugin name="cordova-plugin-sms-retriever-manager" spec="^0.0.2">
<variable name="PLAY_SERVICES_VERSION" value="15.0.1" />
</plugin>
If you are using other plugins which use a different version of play services then you have to align all plugins play services version.
You can change this plugin play services version by changing the above-mentioned tag.
Please copy your config.xml and package.json file for more info.
Thanks!
config.xml
<plugin name="cordova-plugin-camera-preview" spec="^0.10.0" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^2.1.4" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.3" />
<plugin name="cordova-plugin-camera" spec="^4.0.3" />
<plugin name="cordova-plugin-screen-orientation" spec="^3.0.1" />
<plugin name="com.darktalker.cordova.screenshot" spec="^0.1.6" />
<plugin name="cordova-plugin-file" spec="^6.0.1" />
<plugin name="cordova-plugin-geolocation" spec="git+https://github.com/apache/cordova-plugin-geolocation.git">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="To locate you" />
</plugin>
<plugin name="cordova-plugin-nativegeocoder" spec="^3.1.2" />
<plugin name="cordova-plugin-file-opener2" spec="^2.0.19" />
<plugin name="cordova-plugin-x-socialsharing" spec="^5.4.1" />
<plugin name="cordova-plugin-printer" spec="^0.7.3" />
<plugin name="ionic-plugin-deeplinks" spec="^1.0.17">
<variable name="URL_SCHEME" value="rene" />
<variable name="DEEPLINK_SCHEME" value="https" />
<variable name="DEEPLINK_HOST" value="rene.com" />
<variable name="ANDROID_PATH_PREFIX" value="/" />
<variable name="ANDROID_2_PATH_PREFIX" value="/" />
<variable name="ANDROID_3_PATH_PREFIX" value="/" />
<variable name="ANDROID_4_PATH_PREFIX" value="/" />
<variable name="ANDROID_5_PATH_PREFIX" value="/" />
<variable name="DEEPLINK_2_SCHEME" value=" " />
<variable name="DEEPLINK_2_HOST" value=" " />
<variable name="DEEPLINK_3_SCHEME" value=" " />
<variable name="DEEPLINK_3_HOST" value=" " />
<variable name="DEEPLINK_4_SCHEME" value=" " />
<variable name="DEEPLINK_4_HOST" value=" " />
<variable name="DEEPLINK_5_SCHEME" value=" " />
<variable name="DEEPLINK_5_HOST" value=" " />
</plugin>
<plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
<plugin name="cordova-plugin-network-information" spec="^2.0.1" />
<plugin name="cordova-plugin-advanced-http" spec="^2.0.2" />
<plugin name="cordova-plugin-telerik-imagepicker" spec="^2.2.2" />
<plugin name="cordova-plugin-crop" spec="^0.4.0" />
<plugin name="cordova-plugin-file-transfer" spec="^1.7.1" />
<plugin name="cordova-plugin-transfer" spec="^1.0.8" />
<plugin name="cordova-plugin-fullscreen" spec="^1.2.0" />
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
<plugin name="cordova-plugin-fcm-with-dependecy-updated" spec="^2.3.0" />
<plugin name="cordova-plugin-sms-retriever-manager" spec="0.0.2">
<variable name="PLAY_SERVICES_VERSION" value="15.0.1" />
</plugin>
package.json
"dependencies": {
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
"@angular/platform-browser": "5.2.11",
"@angular/platform-browser-dynamic": "5.2.11",
"@ionic-native/android-full-screen": "^4.20.0",
"@ionic-native/android-permissions": "^4.20.0",
"@ionic-native/camera": "^4.15.0",
"@ionic-native/camera-preview": "^4.15.0",
"@ionic-native/core": "~4.12.0",
"@ionic-native/crop": "^4.18.0",
"@ionic-native/deeplinks": "^4.17.0",
"@ionic-native/device": "^4.15.0",
"@ionic-native/fcm": "^4.20.0",
"@ionic-native/file": "^4.15.0",
"@ionic-native/file-opener": "^4.16.0",
"@ionic-native/file-transfer": "^4.18.0",
"@ionic-native/geolocation": "^4.16.0",
"@ionic-native/http": "^4.18.0",
"@ionic-native/image-picker": "^4.18.0",
"@ionic-native/in-app-browser": "^4.17.0",
"@ionic-native/native-geocoder": "^4.16.0",
"@ionic-native/network": "^4.18.0",
"@ionic-native/printer": "^4.17.0",
"@ionic-native/screen-orientation": "^4.15.0",
"@ionic-native/screenshot": "^4.15.0",
"@ionic-native/social-sharing": "^4.17.0",
"@ionic-native/splash-screen": "~4.12.0",
"@ionic-native/status-bar": "~4.12.0",
"@ionic-native/transfer": "^3.14.0",
"@ionic/storage": "^2.2.0",
"@ng-idle/core": "^6.0.0-beta.5",
"@ng-idle/keepalive": "^6.0.0-beta.5",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^2.0.1",
"@types/html2canvas": "0.0.34",
"@types/jquery": "^3.3.22",
"@types/jspdf": "^1.1.31",
"android-versions": "^1.4.0",
"angular2-moment": "^1.9.0",
"com.darktalker.cordova.screenshot": "^0.1.6",
"cordova-android": "7.0.0",
"cordova-plugin-advanced-http": "^2.0.2",
"cordova-plugin-android-permissions": "^1.0.0",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-camera-preview": "^0.10.0",
"cordova-plugin-crop": "^0.4.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-fcm-with-dependecy-updated": "^2.3.0",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-opener2": "^2.0.19",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-fullscreen": "^1.2.0",
"cordova-plugin-geolocation": "git+https://github.com/apache/cordova-plugin-geolocation.git",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^2.1.4",
"cordova-plugin-nativegeocoder": "^3.1.2",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-printer": "^0.7.3",
"cordova-plugin-screen-orientation": "^3.0.1",
"cordova-plugin-sms-retriever-manager": "0.0.2",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-telerik-imagepicker": "^2.2.2",
"cordova-plugin-transfer": "^1.0.8",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-x-socialsharing": "^5.4.1",
"es6-promise-plugin": "^4.2.2",
"html2canvas": "^1.0.0-alpha.12",
"ionic-angular": "3.9.2",
"ionic-plugin-deeplinks": "^1.0.17",
"ionicons": "3.0.0",
"jquery": "^3.3.1",
"rxjs": "5.5.11",
"save": "^2.3.3",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.26"
},
"devDependencies": {
"@ionic/app-scripts": "3.2.0",
"@types/googlemaps": "^3.30.16",
"typescript": "~2.6.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-camera-preview": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-camera": {},
"cordova-plugin-screen-orientation": {},
"com.darktalker.cordova.screenshot": {},
"cordova-plugin-file": {},
"cordova-plugin-geolocation": {
"GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
},
"cordova-plugin-nativegeocoder": {},
"cordova-plugin-file-opener2": {},
"cordova-plugin-x-socialsharing": {},
"cordova-plugin-printer": {},
"ionic-plugin-deeplinks": {
"URL_SCHEME": "rene",
"DEEPLINK_SCHEME": "https",
"DEEPLINK_HOST": "rene.com",
"ANDROID_PATH_PREFIX": "/",
"ANDROID_2_PATH_PREFIX": "/",
"ANDROID_3_PATH_PREFIX": "/",
"ANDROID_4_PATH_PREFIX": "/",
"ANDROID_5_PATH_PREFIX": "/",
"DEEPLINK_2_SCHEME": " ",
"DEEPLINK_2_HOST": " ",
"DEEPLINK_3_SCHEME": " ",
"DEEPLINK_3_HOST": " ",
"DEEPLINK_4_SCHEME": " ",
"DEEPLINK_4_HOST": " ",
"DEEPLINK_5_SCHEME": " ",
"DEEPLINK_5_HOST": " "
},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-fcm-with-dependecy-updated": {},
"cordova-plugin-network-information": {},
"cordova-plugin-advanced-http": {},
"cordova-plugin-telerik-imagepicker": {},
"cordova-plugin-crop": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-transfer": {},
"cordova-plugin-fullscreen": {},
"cordova-plugin-android-permissions": {},
"cordova-plugin-sms-retriever-manager": {
"PLAY_SERVICES_VERSION": "15.0.1"
}
},
"platforms": [
"android"
]
}
@payalkaur
Please check which plugins use google play services(com.google.android.gms:play-services
:) from plugins you have installed.
Probably, These are the plugins which use google play services:
You have to identify which plugin causing the error. as I said, You have to align all plugins with same Play services version.
I think fcm and sms-retriever plugin are getting conflict, its using com.google.firebase:firebase-core:10.+ and com.google.firebase:firebase-messaging:10.+ I tried changing the versions to 15.+ and it builds successfully without any errors but then the app crashes while launching. I am unable to figure out why the app is crashing. Can you suggest what else can be done to solve this issue?
FCM plugin does not provide configuration to set google play services version. so, that there is an issue with it.
I would say go through this URL: https://github.com/fechanique/cordova-plugin-fcm/issues/499 This is not a permanent solution I would say but, this may resolve your issue.
One thing I would suggest is, You can remove the FCM plugin and use Push(phonegap-plugin-push) plugin it has the configuration to set play services version.
as like:
<plugin name="phonegap-plugin-push" spec="^2.2.3">
<variable name="FCM_VERSION" value="15.0.2" />
<variable name="ANDROID_SUPPORT_V13_VERSION" value="27.1.0" />
</plugin>
<plugin name="cordova-plugin-sms-retriever-manager" value="0.0.2">
<variable name="PLAY_SERVICES_VERSION" value="15.0.1" />
</plugin>
Hi @hanatharesh2712 , I solved the conflict between the two plugins. Everything is working properly now. Thank you so much for your help.
Hi, I am trying to use this plugin in Ionic 3. I installed this plugin and created the below function
retriveSMS() { (<any>window)['cordova']['plugins']['smsRetriever']['startWatching']( (result) => { console.log('Message', result); }, (err) => { console.log(err); } ); }
But i am getting "Cannot read property 'plugins' of undefined" error after calling it on button click. It would be really great if you could help me on this.