question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Notification Arrives Two Times

See original GitHub issue

Hello, I am in the midst of porting Native app to React Native and I am facing this issue on React Native side using this library. On my React Native app, the notification arrives two times. This is not an issue on the native app.

This is my OnNotification body

onNotification: function(notification) {
    if (notification.foreground) {
        console.log("NOTIFICATION:", notification);
     }
    PushNotification.localNotification({
        message: notification.alertBody
    });
    console.log(notification);
    if (Platform.OS == "ios") {
        notification.finish(PushNotificationIOS.FetchResult.NoData);
     }
},

Note: I am doing a localNotification call because the server which is not under my control sends alertBody key instead of message so when my app is in background notification never arrives. However, when I send a notification using a service like pushtry it works. So I suspected that this happens because the key is wrong.

This is what I get when I console log the notification object

{
    foreground: false,
    finish: [
        Function: finish`
    ],
    'google.delivered_priority': 'normal',
    'google.sent_time': 1550835432097,
    'google.ttl': 2419200,
    'google.original_priority': 'normal',
    alertBody: 'Lamp has been turned OFF manually',
    deviceStatus: 'OFF',
    deviceScheduleStatus: 'false',
    userInteraction: false,
    id: '888769420',
    badge: '1',
    sound: 'default',
    actionKey: 'DEVICE_ACK_6469',
    'google.message_id': '0:1550835432107983%dcba0139f9fd7ecd',
    actionPending: 'false',
    deviceId: '6469'
}
{
    foreground: false,
    finish: [
      Function: finish
    ],
   alertBody: 'Lamp has been turned OFF manually',
   deviceStatus: 'OFF',
   deviceScheduleStatus: 'false',
   userInteraction: false,
   id: '898772892',
   badge: '1',
   sound: 'default',
   actionKey: 'DEVICE_ACK_6469',
   actionPending: 'false',
   deviceId: '6469'
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

5reactions
zxc20033commented, Feb 28, 2019

please check your AndroidManifest.xml try to remove receiver named com.google.android.gms.gcm.GcmReceiver and service named com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm but keep the receiver named com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher and service named com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService, see if the notification still works and only received once

1reaction
DeVoresyahcommented, Feb 26, 2019

same issue, need to fix asap

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Stop Messages From Ringing Twice on Your iPhone
iOS is set to repeat alerts once for the Messages app, meaning you'll get a second alert for the same message two minutes...
Read more >
Duplicated Notifications - OneSignal Documentation
Usually duplicate notifications occur due to sending the same push data multiple times. If you see multiple notifications sent in your Delivery Tab...
Read more >
How to stop your iPhone from beeping twice when you get a ...
Open Settings and tap Notifications. · Scroll down through the list of apps and tap Messages. · Tap Customize Notifications. · Tap Repeat...
Read more >
Receiving duplicate push notification - Apple Developer
Lately I noticed the I get every push notification duplicate when the device is unlocked and the app is in the background. Probably...
Read more >
Solved: Receiving double notifications on some apps - 130639
... I get two copies of every notification that comes in, ... and when a message comes in on the app, it's posted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found