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

Plugin assumes that if a GCM_SENDER_ID exists then we want to use FCM for notifications #1770

Open
SeeWhat opened this issue Jun 7, 2017 · 6 comments

Comments

@SeeWhat
Copy link

SeeWhat commented Jun 7, 2017

Expected Behaviour

Shouldn't assume that because I have a GoogleService-Info.plist file that I want this plugin to use FCM for notifications.

Actual Behaviour

Forced to use FCM as the GoogleService-Info.plist file contains the GCM_SENDER_ID which can't be removed due to another plugin using Firebase.

It would be good if there was a configuration option to control if FCM should be used if possible.
The registration event would also need to indicate if the token being provided is an FCM or APNS token.

Steps to Reproduce

  1. Install this plugin
  2. Install another plugin which uses FCM, i.e cordova-plugin-firebase-analytics

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Apple iOS 10.2.1

Cordova CLI version and cordova platform version

cordova 7.0.1
cordova-ios 4.0.0

Plugin version

2.0.0-rc4

Code related to issue

https://github.com/phonegap/phonegap-plugin-push/blob/master/src/ios/PushPlugin.m#L318-L329

Logs taken while reproducing problem

Without GCM_SENDER_ID in the GoogleService-Info.plist file the Firebase SDK log the below error

Terminating app due to uncaught exception 'com.firebase.instanceid', reason: 'Could not configure Firebase InstanceID. GCM_SENDER_ID must not be nil or empty.

With the GCM_SENDER_ID in the file, The PushPlugin logs

Using FCM Notification
@macdonst
Copy link
Member

macdonst commented Jun 7, 2017

@SeeWhat really good point. There should be an option in init to indicate to whether or not to use FCM. Thanks for the bug report.

@macdonst
Copy link
Member

@SeeWhat when I remove GCM_SENDER_ID from the GoogleService-Info.plist file or set it to an empty string this plugin reverts to using APNS. I think the error may be coming from the cordova-plugin-firebase-analytics but right now I'm having an issue installing it.

@SeeWhat
Copy link
Author

SeeWhat commented Jun 15, 2017

The error I mentioned (repeated below) is coming from Firebase itself. So you must have the GCM_SENDER_ID entry and it must have a value. The plist does have another entry IS_GCM_ENABLED however it appears that it isn't considered during the Firebase config check and thus doesn't help avoid the error.

Terminating app due to uncaught exception 'com.firebase.instanceid', reason: 'Could not configure Firebase InstanceID. GCM_SENDER_ID must not be nil or empty.

It's a bit of a pain getting cordova-plugin-firebase-analytics installed along with this plugin due to the follow issues

@geo242
Copy link
Contributor

geo242 commented Jun 30, 2017

@macdonst @SeeWhat Is there a workaround for this? I want to use APNS, not FCM in iOS.

@fierysolid
Copy link

fierysolid commented Aug 18, 2017

This needs to go into the documentation somewhere for those people migrating from 1.x to 2.x. This broke my iOS APNS setup because it causes iOS to default to FCM. The Info plist is used for other firebase features as well, so I was not aware this was having an effect on my push notifications.

@petercutting
Copy link

Hi
could someone explain why one would would use more then 1 service eg FCM or APNS if they dont have to. I have got FCM working for Android, and I was about to start on APNS for iOS because I thought I needed both, but now I am not so sure. Can I use FCM for both platforms? In that case why would I want to go near APNS which seems trickyer to configure.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

5 participants