Anthony Krivonos
Anthony Krivonos

Reputation: 4726

Ionic 3 app crashes on startup after installing FCM

Description

I am migrating over from Ionic Push to FCM for my push notifications, as the former has been declared deprecated. The app was running perfectly (committed and saved, of course) before I went on to install FCM using the instructions listed here.

There is no deviation from how I installed this plugin versus how I've installed over twenty other Cordova plugins, but it is evident that FCM is causing this issue because my app has begun to crash on startup ever since I installed the plugin.

Attempts

I've attempted to fix this issue by reinstalling the plugin several times, but I did not have any luck in doing so. Moreover, I scoured the Ionic Framework forum and was not able to find a similar issue. If anyone has experience with FCM and could provide me with any guidance, I'd appreciate it greatly.

Note: The Cordova FCM plugin documentation states that it supports up to Cordova iOS 4.3.1

Ionic System Information

cli packages:

    @ionic/cli-utils  : 1.14.0
    ionic (Ionic CLI) : 3.14.0

global packages:

    cordova (Cordova CLI) : 7.0.1 

local packages:

    @ionic/app-scripts : 1.3.7
    Cordova Platforms  : ios 4.3.1
    Ionic Framework    : ionic-angular 3.2.1

System:

    Android SDK Tools : 26.0.1
    Node              : v8.6.0
    npm               : 5.4.2 
    OS                : macOS Sierra
    Xcode             : Xcode 8.3.3 Build version 8E3004b 

Misc:

    backend : pro

Xcode Debug Output

2017-10-24 23:33:36.693 App[9401:251001] Starting Firebase Analytics plugin
2017-10-24 23:33:36.695 App[9401] <Error> [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more...
2017-10-24 23:33:36.719 App[9401] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40002000 started
2017-10-24 23:33:36.720 App[9401] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2017-10-24 23:33:36.747 App[9401] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-10-24 23:33:36.760 App[9401:251001] [CDVTimer][firebaseanalytics] 67.964017ms
2017-10-24 23:33:36.761 App[9401:251001] [CDVTimer][backgroundfetch] 0.692010ms
2017-10-24 23:33:36.762 App[9401:251001] [CDVTimer][TotalPluginStartup] 148.526013ms
2017-10-24 23:33:36.776 App[9401:251001] DidFinishLaunchingWithOptions
2017-10-24 23:33:36.793 App[9401:251001] *** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Default app has already been configured.'

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="..." version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
      <name>...</name>
      <description>...</description>
      <author email="..." href="">...</author>
      <content original-src="index.html" src="http://...:8100" />
      <access origin="*" />
      <access origin="https://*.google-analytics.com" />
      <access origin="https://*.googleapis.com" />
      <access origin="https://*.firebaseio.com" />
      <access origin="https://*.herokuapp.com" />
      <allow-intent href="http://*/*" />
      <allow-intent href="https://*/*" />
      <allow-intent href="tel:*" />
      <allow-intent href="sms:*" />
      <allow-intent href="mailto:*" />
      <allow-intent href="geo:*" />
      <allow-intent href="http://*/*" />
      <allow-intent href="https://*/*" />
      <allow-intent href="tel:*" />
      <allow-intent href="sms:*" />
      <allow-intent href="mailto:*" />
      <allow-intent href="geo:*" />
      <allow-navigation href="http://ionic.local/*" />
      <allow-navigation href="http://169.254.231.144:8100" />
      <allow-navigation href="http://169.254.83.211:8100" />
      <allow-navigation href="http://169.254.107.228:8100" />
      <allow-navigation href="http://169.254.217.21:8100" />
      <allow-navigation href="http://169.254.164.37:8100" />
      <allow-navigation href="http://169.254.147.106:8100" />
      <allow-navigation href="http://169.254.49.68:8100" />
      <allow-navigation href="http://169.254.124.255:8100" />
      <allow-navigation href="http://172.23.35.244:8100" />
      <allow-navigation href="http://169.254.85.129:8100" />
      <allow-navigation href="http://169.254.198.146:8100" />
      <allow-navigation href="http://169.254.198.146:8101" />
      <allow-navigation href="http://169.254.231.164:8100" />
      <allow-navigation href="http://169.254.158.202:8100" />
      <allow-navigation href="http://169.254.71.169:8100" />
      <allow-navigation href="http://192.168.1.254:8100" />
      <allow-navigation href="http://169.254.44.201:8100" />
      <allow-navigation href="http://169.254.95.130:8100" />
      <allow-navigation href="http://169.254.58.123:8100" />
      <allow-navigation href="http://169.254.63.137:8100" />
      <platform name="android">
            <allow-intent href="market:*" />
            <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
            <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
            <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
            <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
            <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
            <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
            <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
            <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
            <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
            <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
            <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
            <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
            <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
            <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
            <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
            <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
            <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
            <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
      </platform>
      <platform name="ios">
            <allow-intent href="itms:*" />
            <allow-intent href="itms-apps:*" />
            <icon height="57" src="resources/ios/icon/icon.png" width="57" />
            <icon height="114" src="resources/ios/icon/[email protected]" width="114" />
            <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
            <icon height="80" src="resources/ios/icon/[email protected]" width="80" />
            <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
            <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
            <icon height="100" src="resources/ios/icon/[email protected]" width="100" />
            <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
            <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
            <icon height="180" src="resources/ios/icon/[email protected]" width="180" />
            <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
            <icon height="144" src="resources/ios/icon/[email protected]" width="144" />
            <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
            <icon height="152" src="resources/ios/icon/[email protected]" width="152" />
            <icon height="167" src="resources/ios/icon/[email protected]" width="167" />
            <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
            <icon height="58" src="resources/ios/icon/[email protected]" width="58" />
            <icon height="87" src="resources/ios/icon/[email protected]" width="87" />
            <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
            <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
            <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
            <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
            <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
            <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
            <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
            <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
            <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
            <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
            <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
            <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
      </platform>
      <preference name="fullscreen" value="true" />
      <preference name="ShowSplashScreenSpinner" value="false" />
      <preference name="webviewbounce" value="false" />
      <preference name="UIWebViewBounce" value="false" />
      <preference name="DisallowOverscroll" value="true" />
      <preference name="android-minSdkVersion" value="16" />
      <preference name="KeyboardDisplayRequiresUserAction" value="false" />
      <preference name="BackupWebStorage" value="none" />
      <preference name="SplashMaintainAspectRatio" value="true" />
      <preference name="FadeSplashScreenDuration" value="0" />
      <preference name="SplashShowOnlyFirstTime" value="false" />
      <preference name="SplashScreen" value="screen" />
      <preference name="SplashScreenDelay" value="1000" />
      <feature name="StatusBar">
            <param name="ios-package" onload="true" value="CDVStatusBar" />
      </feature>
      <icon src="resources/ios/icon/[email protected]" />
      <allow-navigation href="http://10.216.91.134:8100" />
      <allow-navigation href="http://10.216.154.27:8100" />
      <allow-navigation href="http://169.254.64.106:8100" />
      <allow-navigation href="http://10.60.4.249:8100" />
      <allow-navigation href="http://169.254.94.128:8100" />
      <allow-navigation href="http://10.216.84.155:8100" />
      <allow-navigation href="http://10.216.84.155:8101" />
      <allow-navigation href="http://192.168.1.254:8101" />
      <allow-navigation href="http://169.254.132.69:8101" />
      <allow-navigation href="http://172.20.10.3:8100" />
      <allow-navigation href="http://10.216.88.170:8100" />
      <allow-navigation href="http://10.216.84.170:8100" />
      <allow-navigation href="http://169.254.254.145:8100" />
      <allow-navigation href="http://169.254.211.187:8100" />
      <allow-navigation href="http://10.216.90.211:8100" />
      <allow-navigation href="http://169.254.180.116:8101" />
      <allow-navigation href="http://10.216.90.63:8100" />
      <allow-navigation href="http://10.60.5.112:8100" />
      <allow-navigation href="http://169.254.8.28:8100" />
      <allow-navigation href="http://169.254.90.171:8100" />
      <allow-navigation href="http://169.254.84.156:8100" />
      <allow-navigation href="http://169.254.30.100:8100" />
      <allow-navigation href="http://10.216.91.188:8100" />
      <allow-navigation href="http://10.60.7.23:8100" />
      <allow-navigation href="http://10.216.85.235:8100" />
      <allow-navigation href="http://169.254.39.189:8100" />
      <allow-navigation href="http://10.216.86.138:8100" />
      <allow-navigation href="http://169.254.117.243:8100" />
      <allow-navigation href="http://10.216.87.159:8100" />
      <allow-navigation href="http://169.254.127.19:8100" />
      <allow-navigation href="http://10.60.3.195:8100" />
      <allow-navigation href="http://10.216.87.58:8100" />
      <allow-navigation href="http://10.60.3.176:8100" />
      <allow-navigation href="http://169.254.223.25:8100" />
      <allow-navigation href="http://10.216.85.255:8100" />
      <allow-navigation href="http://169.254.82.147:8100" />
      <allow-navigation href="http://172.31.98.12:8100" />
      <allow-navigation href="http://10.216.86.184:8100" />
      <allow-navigation href="http://10.60.1.94:8100" />
      <engine name="ios" spec="^4.3.1" />
      <plugin name="com.telerik.plugins.nativepagetransitions" spec="~0.6.5" />
      <plugin name="cordova-plugin-app-version" spec="^0.1.9" />
      <plugin name="cordova-plugin-background-fetch" spec="^5.0.0" />
      <plugin name="cordova-plugin-badge" spec="~0.8.1" />
      <plugin name="cordova-plugin-cocoapod-support" spec="^1.3.0" />
      <plugin name="cordova-plugin-compat" spec="^1.1.0" />
      <plugin name="cordova-plugin-console" spec="^1.0.7" />
      <plugin name="cordova-plugin-contacts" spec="^2.3.1">
            <variable name="CONTACTS_USAGE_DESCRIPTION" value=" " />
      </plugin>
      <plugin name="cordova-plugin-device" spec="^1.1.6" />
      <plugin name="cordova-plugin-email-composer" spec="^0.8.8" />
      <plugin name="cordova-plugin-facebook4" spec="git+https://github.com/jeduan/cordova-plugin-facebook4.git">
            <variable name="APP_ID" value="..." />
            <variable name="APP_NAME" value="..." />
      </plugin>
      <plugin name="cordova-plugin-fcm" spec="^2.1.2" />
      <plugin name="cordova-plugin-firebase-analytics" spec="^0.10.1" />
      <plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />
      <plugin name="cordova-plugin-native-keyboard" spec="^1.4.1">
            <variable name="LICENSE" value="TRIAL" />
      </plugin>
      <plugin name="cordova-plugin-nativestorage" spec="^2.2.2" />
      <plugin name="cordova-plugin-network-information" spec="^1.3.3" />
      <plugin name="cordova-plugin-sim" spec="^1.3.3" />
      <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
      <plugin name="cordova-plugin-statusbar" spec="^2.2.3" />
      <plugin name="cordova-plugin-vibration" spec="^2.1.5" />
      <plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
      <plugin name="cordova-sms-plugin" spec="^0.1.11" />
      <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
      <plugin name="mx.ferreyra.callnumber" spec="~0.0.2" />
      <plugin name="phonegap-plugin-push" spec="^2.0.0">
            <variable name="SENDER_ID" value="..." />
      </plugin>
</widget>

Desired Outcome/Solution

Loading my Ionic 3 app without crashing using ionic cordova build ios.

Upvotes: 2

Views: 2716

Answers (2)

Rodrigo Chaves
Rodrigo Chaves

Reputation: 1114

I'm answering this question even that already have an accepted answer because the current solution didn't help me. I hope it help others in same situation.

To fix this crash, I current checked if <projectRoot>/platforms/ios/<appname>/Resources/GoogleService-Info.plist and <projectRoot>/platforms/ios/<appname>/Resources/Resources/GoogleService-Info.plist aren't corrupted. In my case, the second file was corrupted and I replaced with the original one that I downloaded from Firebase Cloud Messasing.

Then everything started working fine now!

Upvotes: 3

jcesarmobile
jcesarmobile

Reputation: 53301

This is a bug on the plugin, you can see this issue open with the same error message.

He should change the code to be something like this:

if([FIRApp defaultApp] == nil) {
    [FIRApp configure]; 
}

I have just sent a PR fixing it

Upvotes: 4

Related Questions