wix / react-native-notifications

React Native Notifications
MIT License
3.23k stars 763 forks source link

Crash app when recieve Notification in IOS 14 #1009

Closed nqam1904 closed 7 months ago

nqam1904 commented 11 months ago

Hello! I am experiencing an issue when receiving notifications on an iPhone device with iOS 14 or 15. When I push a real device into the background, I encounter the issue as shown in the image. After building the app on TestFlight, if the app is in the foreground and a notification arrives, it crashes the app in the foreground. On Android 13, it doesn't show in the foreground on all devices. Can you please assist me with this issue?

image

"react-native-notifications": "^5.1.0", "react-native": "^0.69.6",

nqam1904 commented 10 months ago

No one cares about me :<

msabree commented 10 months ago

Seems to be caused by calling completion. I just commented it out to get by for now.

omartamer-git commented 9 months ago

Any updates on this? I am facing this issue as well.

poojagupta-trilogy commented 7 months ago

Any update on this, I am also facing this issue.

ceebows commented 7 months ago

Also have issue with. completion handler seems to crash app when i receive a notification in foreground. iOS is setup according to documentation.

it used to work.

package.json

"react-native": "^0.73.2",
"react-native-notifications": "^5.1.0",

I am using react navigation as well. code example (pretty much the same as documentation) inside my main component which is several layers deep inside stack navigators and a navigationcontainer:

Notifications.registerRemoteNotifications();

 Notifications.events().registerNotificationReceivedForeground((notification, completion) => {
     console.log(`Notification received in foreground: ${notification.title} : ${notification.body}`);
     completion({
         alert: true,
         sound: true,
         badge: false
     });
 });

 Notifications.events().registerNotificationOpened((notification, completion) => {
     console.log(`Notification opened: ${notification.payload}`);
     completion();
 });

Edit the completion handler is undefined

nqam1904 commented 7 months ago

I have successfully fixed it because I initialized twice in React Native, so it caused an error. But I switched to using react-native-push-notification, which is stable and resolves the issue I was facing. Thank you, everyone, for your attention. I request to close the issue here.