react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
732 stars 281 forks source link

Double notifications on IOS only Foreground State, Background and kill Working fine #379

Closed viv578ek closed 1 year ago

viv578ek commented 1 year ago

I am getting 2 Notifications in foreground state. Same In Kill and Background working fine

Version : - "@react-native-community/push-notification-ios": "^1.8.0", react-native: 0.62.3 Notification Type : APNS Alert

We received 2 different NotificationId same time like :-

  1. &&&&& App:: onNotif called {"action": undefined, "badge": 1, "data": {"notificationId": "5D37FB9D-A6BE-418D-913A-9F6C62957CA6", "remote": true}, "finish": [Function finish], "foreground": true, "id": undefined, "message": "You have missed call from \"1008\"", "reply_text": undefined, "soundName": "default", "subtitle": undefined, "title": "Missed Call", "userInteraction": false} 2: - &&&&& App:: onNotif called {"action": undefined, "badge": 1, "data": {"notificationId": "C1010B25-2DD1-4086-B6EA-0FABB3F3A91A", "remote": true}, "finish": [Function finish], "foreground": true, "id": undefined, "message": "You have missed call from \"1008\"", "reply_text": undefined, "soundName": "default", "subtitle": undefined, "title": "Missed Call", "userInteraction": false}

Received 2 Different Notification Id : "notificationId": "5D37FB9D-A6BE-418D-913A-9F6C62957CA6", "notificationId": "C1010B25-2DD1-4086-B6EA-0FABB3F3A91A",

All Notification Received onNotif event async onNotif(notif) { console.log("&&&&& App:: onNotif called", notif);

Note : Same Case Working in Background and Kill State but foreground case received 2 Notification. And Also we received 2 event only foreground state

Please help me if you have any idea for this issues.

viv578ek commented 1 year ago

I have found the solution In App delegate we have added 2 time didReceiveRemoteNotification

Now it working fine