簡體   English   中英

使用 react-native-push-notification,App 在收到新的 FCM 通知時崩潰

[英]Using react-native-push-notification, App crashes when receiving new FCM notification

我試圖在 react-native 應用程序上添加推送通知,所以我使用了 react-native-push-notification。 庫配置進行得很順利,但是當收到通知時,APP 立即崩潰,說“FirebaseApp 未初始化”。

崩潰報告AndroidRuntime:java.lang.IllegalStateException:默認 FirebaseApp 未在此 com.myapp 中初始化。 確保首先調用 FirebaseApp.initializeApp(Context)。

如何初始化 FirebaseApp 或解決此問題? 任何幫助將不勝感激。

有關更多信息,請打開 Github 問題https://github.com/zo0r/react-native-push-notification/issues/852

好! 它現在有效。

的build.gradle

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:+'
    }
}

應用程序/的build.gradle

// At the very bottom of the file
apply plugin: 'com.google.gms.google-services'

信用https://github.com/zo0r/react-native-push-notification/issues/852#issuecomment-417641675

當我將 AndroidManifest.xml 更改為

    <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<application ....>
    <!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                android:value="false"/>
    <!-- Change the resource name to your App's accent color - or any other color you want -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
    <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" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
        </intent-filter>
    </receiver>

    <service
        android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM