Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Incorrect APNS token is getting generated by phonegap-push-plugin when the app contain the firebase plugin for analytics #2784

Closed
paamrutk opened this issue Jun 27, 2019 · 5 comments

Comments

@paamrutk
Copy link

We are using ionic cordova phonegap-push plugin for Push notifications and Firebase plugin for analytics in our ionic application.

In iOS,Push notifications are sent through APNS and in android, push notifications are sent through FCM. In android, push notifications are working fine but in iOS, push notifications are not working.

In iOS , due to the firebase setup, Google-Services-Info.plist file has been added to the project.
In PushPlugin.m file, there are bits of codes written which read the plist file and picks up the fcm sender id and the field isGCMEnabled from the plist file and generates the FCM token instead of the APNS token, which is then passed to the application.

Since the push notification services expects the APNS token instead of the FCM token, hence the push notifications are not received on the device.

Token which was getting generated before the firebase setup is:
0a8f78c2780b39b2ec80e9dc1716577e39e1dfbc13cb5f7260541a98ed3ca23d

Token which is getting generated after the firebase setup is:
cfIrBZsnSi8:APA91bFPG-R77CTV0KSmXKxuvVPlk8WFGjDWH3Sg_ZO8kcQOKNs_IPxdFHJyKTdfQjxZcGb64hom17v_HJKcIZtp4l0-ceEqz3HDhGwyYMZhJkLUeAQirtkxNoF2DFjDTqzA8CAEidAe

Please suggest the solution for this.

FYI
"@ionic-native/firebase": "^4.19.0",
"@ionic-native/push": "^4.16.0",
"phonegap-plugin-push": "^2.2.3",

ionic info:

Ionic:
ionic (Ionic CLI) : 4.10.3 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.6
@ionic/app-scripts : 3.2.4
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : android 7.1.4, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, (and 22 other plugins)
System:
NodeJS : v10.15.1 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Mojave

@matscav
Copy link

matscav commented Jun 28, 2019

I had the same problem. All you have to do is edit your GoogleService-Info.plist and change this:
<key>IS_GCM_ENABLED</key> <true></true>
To this:
<key>IS_GCM_ENABLED</key> <false></false>
After that you will receive APNS token again.

@luisvillara
Copy link

@matscav Thank you so much! It's working now!!!

@paamrutk
Copy link
Author

paamrutk commented Jul 1, 2019

@matscav : We tried this approach. For the first time we are able to generate the APNS token with this and we are able to capture this token and send to our backend but again I don't know somehow again FCM token gets generated.
Hence there is a mismatch that happens between the backend where APNS token is stored and the app side where FCM token gets stored because of which notifications are not coming on the device.

Can you please help us on this.

const options: PushOptions = {
android: {
icon: 'app_icon',
senderID: this.senderId
},
ios: {
alert: PageValues.BOOLEAN_VALUES.STRING_TRUE,
badge: PageValues.BOOLEAN_VALUES.BOOLEAN_FALSE,
sound: PageValues.BOOLEAN_VALUES.STRING_TRUE
}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('registration').subscribe((data: any) => {
console.log('api:Notification Token' + data.registrationId);
this.globalHandler.setNotificationToken(data.registrationId);
});

@shankari
Copy link

shankari commented Jul 20, 2019

@paamrutk are you sure you are getting the FCM token locally? It seems pretty clear from the code that setUsesFCM is NO if IS_GCM_ENABLED is NO

Can you post your logs here?

When I run this with IS_GCM_ENABLED, I get the following logs in xcode

2019-07-20 14:18:26.526280-0700 emTripLog[6681:3048354] Using FCM Notification
2019-07-20 14:18:29.729606-0700 emTripLog[6681:3047817] FCM Registration Token: e0jPBt...
2019-07-20 14:18:29.748053-0700 emTripLog[6681:3047817] DEBUG: Token = {"token":"e0jPBt...","type":"FCM"}

while with APNS, I get

2019-07-20 16:11:00.861120-0700 emTripLog[6753:3067658] Using APNS Notification
2019-07-20 16:11:02.144457-0700 emTripLog[6753:3067095] DEBUG:Token = {"token":"34976...","type":"APNS"}
2019-07-20 16:11:02.144671-0700 emTripLog[6753:3067095] DEBUG: Token = {"token":"34976...","type":"APNS"}

Can you check the type of the token and post additional logs?

@paamrutk paamrutk closed this as completed Dec 4, 2019
@lock
Copy link

lock bot commented Jan 3, 2020

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants