Search code examples
iosfirebaseionic-frameworkcordova-plugin-fcm

Firebase Plugins not Working on IOS (Ionic)


I am developing an Ionic App, and I am having some issues with the IOS App and Firebase/FCM Plugins.


The Android App is working perfectly with the below plugins installed:

ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated
npm install @ionic-native/fcm

As for the IOS App I tried several Plugins and none is working:

Option 1:

ionic cordova plugin add cordova-plugin-fcm
npm install @ionic-native/fcm

The app is building successfully, but it is failing when launched on an iPhone. When debugging, I am getting this error Message:

Terminating app due to uncaught exception 'com.firebase.core', reason: 'Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.'

Option 2:

ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated
npm install @ionic-native/fcm

When building with this plugin, I am getting the below error in xCode:

** ARCHIVE FAILED **


The following build commands failed:
        CompileC /Users/walid/Library/Developer/Xcode/DerivedData/Nutripro-aabwvacmftjwnefthwnyidfyxswx/Build/Intermediates.noindex/ArchiveIntermediates/Nutripro/IntermediateBuildFilesPath/Nutripro.build/Release-iphoneos/Nutripro.build/Objects-normal/arm64/FCMPlugin.o /Users/walid/Documents/www/nutripro/platforms/ios/Nutripro/Plugins/cordova-plugin-fcm-with-dependecy-updated/FCMPlugin.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
xcodebuild: Command failed with exit code 65
[ERROR] An error occurred while running subprocess cordova.

I searched alot to find a solution for this error, and I can't find any.

Option 3:

ionic cordova plugin add cordova-plugin-firebase
npm install @ionic-native/firebase

I can build an App successfully using this plugin, and I can run it on my iPhone and a Token is generated and I can receive Push Notifications Normally. But the problem here is happening when Uploading the App to the App Store

  • Archiving on xCode is Successful
  • When Distributing/Uploading the App, I am getting the below Error:
ERROR ITMS-90771: "Missing Info.plist value. The Info.plist key 'BGTaskSchedulerPermittedIdentifiers' must contain a list of identifiers used to submit and handle tasks when 'UIBackgroundModes' has a value of 'processing'. For more information, refer to the Information Property List Key Reference at https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html."

I searched the Internet and found this article stating that I must add the below to my info.plist file

<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
    <string>com.nutripro.mobile</string>
</array>

After adding it and Resubmitting my Application, I am getting an email back from Apple

Dear Developer,

We identified one or more issues with a recent delivery for your app, "NutriPro" 1.1.11 (1.1.11). Please correct the following issues, then upload again.

ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview).

Best regards,

The App Store Team

If I remove the plugin, the App is being uploaded and approved.

The weird thing is that the documentation on @ionic-native/firebase says that they got rid of the UIWebView and are using WKWebView


N.B: After Each Option, I am uninstalling the installed Package and Node Module, and I am deleting the platforms folder.

Do you guys have any idea how I can fix this issue? I've been trying to figure out a solution for almost 1 week and I can't find any!


Solution

  • After a lot of research and unsuccessful attempts, I found a solution.

    For Android, I am using fcm-with-dependecy-updated

    ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated
    npm install @ionic-native/fcm
    

    For IOS, I am using firebase-messaging

    ionic cordova plugin add cordova-plugin-firebase-messaging
    npm install @ionic-native/firebase-messaging