重复通知 - react-native-push-notification

Duplicate notifications - react-native-push-notification

我在 Android 上的 react-native-push-notification 模块有问题。正确设置后,会为生成的设备令牌发送通知。不幸的是,每个推送通知都是重复的。

那一刻我没有实现频道名称,远程推送通知被传递到 "Other" 类别两次。当有频道名称时 Android 在通知中显示推送通知为 "Other""Category Name"模块。

<meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
                android:value="Channel Name"/>
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
                android:value="Channel description"/>

有没有可能只留下一个推送通知。我确定推送通知会发送一次。

我知道该库不受支持,但不幸的是我没有时间进行更改。我需要快速修复。

我很乐意提供帮助!

我也遇到了同样的问题, 然后我意识到文档中存在误解。

我是怎么解决的?

转到 AndroidManifest.xml 并删除此 :-

<!-- < Only if you're using GCM or localNotificationSchedule() > -->
        <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="${applicationId}" />
            </intent-filter>
        </receiver>
<!-- < Only if you're using GCM or localNotificationSchedule() > -->

只需要一个接收者,而图书馆提到了 2 个接收者,所以删除这个接收者以停止接收重复的通知。

我在我的 React Native 应用程序中遇到了相同的托盘通知问题。

发生这种情况是因为我使用 PushNotification.createChannel({...}) 注册了两个通知渠道。

所以,我所要做的就是为不必要的频道调用 PushNotification.deleteChannel('DUPLICATE_CHANNEL_ID')。我只在应用程序启动时的通知配置中调用了一次 dfelete 方法。