1
votes

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!

2
Are they being duplicated on both Android and iOS? Or only one platform? - PGMacDesign
This app is made only for Android and I could not test it on iOS. - Dzeremix

2 Answers

3
votes

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.

1
votes

I had the same, double-notification-in-tray, problem in my React Native app.

It happened because I registered TWO channels for notifications with PushNotification.createChannel({...}).

So, all I had to do was to call PushNotification.deleteChannel('DUPLICATE_CHANNEL_ID') for the unnecessary channel. I called the dfelete method only once, in my notification-configuration upon app start-up.