首页 > 解决方案 > 在同一个 React 本机应用程序中使用 LocalNotificationSchedule 和 Firebase 通知

问题描述

有没有办法在 React Native 应用程序中同时使用 localNotificationSchedule 和 Firebase 远程推送通知?使用https://github.com/zo0r/react-native-push-notification上的公共库表示 AndroidManifest.xml 需要两种不同的服务

<!-- < Only if you're using GCM or localNotificationSchedule() > -->
    <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>
    <!-- </ Only if you're using GCM or localNotificationSchedule() > -->

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

那么我必须选择其中任何一个吗?

标签: reactjsfirebasereact-nativepush-notificationfirebase-cloud-messaging

解决方案


我自己在使用 OneSignal,但我可以告诉你,如果你想使用本地通知,你需要同时添加两者。

此外,GCM 将在几周内被弃用,因此您不想使用它。只需使用 Firebase 的 FCM。


推荐阅读