Skip to content
This repository has been archived by the owner. It is now read-only.

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

Open
laagland opened this issue Aug 9, 2018 · 12 comments
Open

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

laagland opened this issue Aug 9, 2018 · 12 comments

Comments

@laagland
Copy link
Contributor

@laagland laagland commented Aug 9, 2018

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
Copy link

@mark-veenstra mark-veenstra commented Aug 9, 2018

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

Loading

@macdonst
Copy link
Member

@macdonst macdonst commented Aug 9, 2018

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

Loading

@ecert
Copy link

@ecert ecert commented Oct 2, 2018

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)

Loading

@egantz
Copy link

@egantz egantz commented Oct 3, 2018

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

Loading

@Vikum94
Copy link

@Vikum94 Vikum94 commented Oct 14, 2018

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

Loading

@mark-veenstra
Copy link

@mark-veenstra mark-veenstra commented Oct 15, 2018

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

Loading

@egantz
Copy link

@egantz egantz commented Oct 15, 2018

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.

Loading

@2mia
Copy link

@2mia 2mia commented Oct 21, 2018

image

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

Loading

@assafshp
Copy link

@assafshp assafshp commented Oct 21, 2018

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

Loading

@olaferlandsen
Copy link

@olaferlandsen olaferlandsen commented Nov 27, 2018

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...

Loading

@rakeshpalivela
Copy link

@rakeshpalivela rakeshpalivela commented Feb 5, 2019

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.

Loading

@loubog
Copy link

@loubog loubog commented May 15, 2019

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

Loading

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

Successfully merging a pull request may close this issue.

None yet
12 participants