React-native-push-notification: Default FirebaseApp is not initialized in this process

Created on 9 Aug 2019  路  12Comments  路  Source: zo0r/react-native-push-notification

I sending push notification node-gcm to my token. Yey i have token. .configure({ }) is working. But the application crashes directly when I use the plugin and throw notification. This time I'm sending it again after the crash comes notification. When I try for the 3rd time, the app doesn't come crashed.

Everyone said check xml file. I couldn't find my fault. I think the readme.md file should be given piece by piece information about the xml file

For example;
For Local Notification ...
For GCM ...
For FCM ...

RN Version: 0.60.4
OS: Android
OS Version: 9
Plugin Version: lastest

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.localreminder.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
...
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
        android:value="YOUR NOTIFICATION CHANNEL NAME"/>
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
            android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
            android:resource="@android:color/white"/>
<receiver
    android:name="com.google.android.gms.gcm.GcmReceiver"
    android:exported="true"
    android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="com.localreminder" />
    </intent-filter>
</receiver>

<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
    android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
</service>

Error

java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.localreminder. Make sure to call FirebaseApp.initializeApp(Context) first.
    at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@17.1.0:186)
    at com.google.firebase.messaging.MessagingAnalytics.zza(com.google.firebase:firebase-messaging@@19.0.1:75)
    at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(com.google.firebase:firebase-messaging@@19.0.1:2)
    at com.google.firebase.messaging.FirebaseMessagingService.zzc(com.google.firebase:firebase-messaging@@19.0.1:50)
    at com.google.firebase.messaging.zzg.run(com.google.firebase:firebase-messaging@@19.0.1:2)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
    at java.lang.Thread.run(Thread.java:764)


Most helpful comment

I stumbled upon the same problem in android, and I was only using local notifications.

Seems that firebase is called when configuring the library with requestPermissions: true.

This fixed the problem for me:

PushNotification.configure({
//...
 requestPermissions: Platform.OS === 'ios'
//...
}

All 12 comments

I sending push notification node-gcm to my token. Yey i have token. .configure({ }) is working. But the application crashes directly when I use the plugin and throw notification. This time I'm sending it again after the crash comes notification. When I try for the 3rd time, the app doesn't come crashed.

Everyone said check xml file. I couldn't find my fault. I think the readme.md file should be given piece by piece information about the xml file

For example;
For Local Notification ...
For GCM ...
For FCM ...

RN Version: 0.60.4
OS: Android
OS Version: 9
Plugin Version: lastest

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.localreminder.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
...
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
        android:value="YOUR NOTIFICATION CHANNEL NAME"/>
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
            android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
            android:resource="@android:color/white"/>
<receiver
    android:name="com.google.android.gms.gcm.GcmReceiver"
    android:exported="true"
    android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="com.localreminder" />
    </intent-filter>
</receiver>

<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
    android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
</service>

Error

java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.localreminder. Make sure to call FirebaseApp.initializeApp(Context) first.
  at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@17.1.0:186)
  at com.google.firebase.messaging.MessagingAnalytics.zza(com.google.firebase:firebase-messaging@@19.0.1:75)
  at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(com.google.firebase:firebase-messaging@@19.0.1:2)
  at com.google.firebase.messaging.FirebaseMessagingService.zzc(com.google.firebase:firebase-messaging@@19.0.1:50)
  at com.google.firebase.messaging.zzg.run(com.google.firebase:firebase-messaging@@19.0.1:2)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
  at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
  at java.lang.Thread.run(Thread.java:764)

Hello! Did you find a solution of your problem?

I stumbled upon the same problem in android, and I was only using local notifications.

Seems that firebase is called when configuring the library with requestPermissions: true.

This fixed the problem for me:

PushNotification.configure({
//...
 requestPermissions: Platform.OS === 'ios'
//...
}

Hi @arqex
Thanks for sharing this!
It鈥檚 a good way to avoid crash for Android when you are not using Firebase 馃憤

I have had the same problem an Android, but this solution didn't worked for me.

Instead, running watchman watch-del-all && react-native start --reset-cache, solved it and now finally I am able to run the App and receive push notification token ad onRegister().

+1 for @arqex
His solution worked for me! Ran into other syntax issues with the readme's setup/installation guide pertaining to the config object being sent to PushNotification.localNotification({...}).

HTH

Follow-up.. this only helped with local notifications. Still trying to get remote notifications to work. (O_o)

Hi @odnarb
Just follow the firebase installation for Android in the official documentation of Firebase.

I stumbled upon the same problem in android, and I was only using local notifications.

Seems that firebase is called when configuring the library with requestPermissions: true.

This fixed the problem for me:

PushNotification.configure({
//...
 requestPermissions: Platform.OS === 'ios'
//...
}

Thanks. It's work for me.

@arqex thnx u so much worked for me.

I stumbled upon the same problem in android, and I was only using local notifications.

Seems that firebase is called when configuring the library with requestPermissions: true.

This fixed the problem for me:

PushNotification.configure({
//...
 requestPermissions: Platform.OS === 'ios'
//...
}

thank you a lot !!! you saved me hours

I stumbled upon the same problem in android, and I was only using local notifications.

Seems that firebase is called when configuring the library with requestPermissions: true.

This fixed the problem for me:

PushNotification.configure({
//...
 requestPermissions: Platform.OS === 'ios'
//...
}

Thanks for you! Its worked for me!

Was this page helpful?
0 / 5 - 0 ratings