Search code examples
androidreact-nativepush-notificationreact-native-push-notification

Duplicate notifications - react-native-push-notification


I have a problem with react-native-push-notification module on Android. After correct set up the notifications are delivered for generated device token. Unfortunately, every push notification is duplicated.

At that moment I do not implement the channel name and the remote push notification is delivered twice to "Other" category. When there is a channel name Android displays the push notification as "Other" and "Category Name" in the Notification Module.

<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"/>

Is there any possibility to leave only one push notification. I am sure that push notification is sent once.

I know that the library is not supported but unfortunately I do not have time for a change. I need a quick fix.

I will be glad for help!


Solution

  • I also was going through same problem, Then i realized there was misunderstanding in the documentation.

    How i solved it?

    Go to AndroidManifest.xml and remove this :-

    <!-- < 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() > -->
    
    

    Only one receiver is required while the library has mentioned 2 receivers so remove this one to stop receiving the duplicate notification.