phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

iOS on FCM not working for debug signed apps + workaround #2518

Open laagland opened 6 years ago

laagland commented 6 years ago

Expected Behaviour

When configuring iOS on FCM notifications for debug-signed apps should arrive.

Actual Behaviour

Sending notifications gives a 'InvalidRegistration' error and when attempted a second time with the same FCM token, a 'NotRegistered' error.

Steps to Reproduce

We use separate debug & production versions of our apps. When using a debug-only version, we couldn't get notifications delivered to our client apps.

Using the debugger in Xcode, we noticed the following error from Firebase:

[Firebase/InstanceID][I-IID003014] Error while reading embedded mobileprovision Error Domain=NSCocoaErrorDomain Code=260 "The file “embedded.mobileprovision” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/var/containers/Bundle/Application/XXX/embedded.mobileprovision, NSUnderlyingError=0x28127d620 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

It turns out that Cordova uses a hook during the ios-build, which removes the embedded.mobileprovision that Firebase uses to determine if this is a production app or not. Because this is missing, debug-only signed apps will not receive the correct FCM token when the plugin makes a request to Firebase.

A workaround is to comment out the line to prevent the removal of the file during the debug build (line 56 in platforms/ios/cordova/lib/copy-www-build-step.js). An issue was created to fix this in cordova, see https://issues.apache.org/jira/browse/CB-14264

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

iOS 12 on iPhone & iPad

Cordova CLI version and cordova platform version

cordova-cli 8.0 cordova-ios 4.5.5

Plugin version

phonegap-plugin-push v2.2.3

mark-veenstra commented 6 years ago

A workaround is to comment out the line to prevent the removal of the file during the debug build (line 56 in platforms/ios/cordova/lib/copy-www-build-step.js).

This could be done by added a hook to the plugin which will execute after platform add and or removes the line or comments it out

macdonst commented 6 years ago

@laagland let's vote up the cordova issue so it gets fixed. I just voted and started watching it.

ecert commented 6 years ago

Hi there, Cordova project on Xcode10 is failure for FCM because of XCode's new build system.

If you want to use Google FCM Push Notification with iOS device (Coding with Cordova / Ionic 3) try this; Opening your cordova/ionic project in the Xcode IDE and change the build system in Workspace Settings to "Legacy Build System". (Under the File Menu)

egantz commented 6 years ago

@ecert works perfectly! So now we need to wait for a fix in order to return back to the new build system?

Vikum94 commented 6 years ago

Hi there, Cordova project on Xcode10 is failure for FCM because of XCode's new build system.

If you want to use Google FCM Push Notification with iOS device (Coding with Cordova / Ionic 3) try this; Opening your cordova/ionic project in the Xcode IDE and change the build system in Workspace Settings to "Legacy Build System". (Under the File Menu)

This worked for me with ionic 3.9. Thanks for the fix (y) @ecert

mark-veenstra commented 6 years ago

Seems to me that the XCode 10 issue is a different kind of issue then the one we are focusing on here.

egantz commented 6 years ago

Hi there, Cordova project on Xcode10 is failure for FCM because of XCode's new build system.

If you want to use Google FCM Push Notification with iOS device (Coding with Cordova / Ionic 3) try this; Opening your cordova/ionic project in the Xcode IDE and change the build system in Workspace Settings to "Legacy Build System". (Under the File Menu)

It's actually fixes the issue with iOS12 but breaks any previous version of iOS.

2mia commented 6 years ago

image

I confirm commenting out ☝️ line 56 fixed FCM pushes for debug builds.

assafshp commented 6 years ago

@2mia it's also works for me !!!! many thanks !

olaferlandsen commented 5 years ago

Hi there, Cordova project on Xcode10 is failure for FCM because of XCode's new build system.

If you want to use Google FCM Push Notification with iOS device (Coding with Cordova / Ionic 3) try this; Opening your cordova/ionic project in the Xcode IDE and change the build system in Workspace Settings to "Legacy Build System". (Under the File Menu)

So go to:

Xcode > File > Workspace Settings...

rakeshpalivela commented 5 years ago

Hi there, Cordova project on Xcode10 is failure for FCM because of XCode's new build system.

If you want to use Google FCM Push Notification with iOS device (Coding with Cordova / Ionic 3) try this; Opening your cordova/ionic project in the Xcode IDE and change the build system in Workspace Settings to "Legacy Build System". (Under the File Menu)

This working for me in Xcode 10.1. Thanks.

loubog commented 5 years ago

Hi there, Cordova project on Xcode10 is failure for FCM because of XCode's new build system.

If you want to use Google FCM Push Notification with iOS device (Coding with Cordova / Ionic 3) try this; Opening your cordova/ionic project in the Xcode IDE and change the build system in Workspace Settings to "Legacy Build System". (Under the File Menu)

Worked for me as well. Thanks