react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

Local notification not showing while app is open (iOS 11)

Open mahyarr opened this issue 8 years ago • 9 comments

Hello,

I'm trying to show a local notification on iOS 11 while the app is open and it never displays. I placed a breakpoint inside the function userNotificationCenter:willPresentNotification:withCompletionHandler of file notifications/RNFirebaseNotifications.m and strangely enough it's not being called even though the delegate is set properly inside the constructor.

When the app is in background, local notifications show up just fine.

Any idea what could be happening here?


react-native-firebase: 4.2.0 react-native: 0.55.4

mahyarr avatar May 24 '18 22:05 mahyarr

@mahyarr How are you trying to show the local notification? Do you have a code snippet?

chrisbianca avatar May 29 '18 12:05 chrisbianca

Yes, here's what I'm using:

const notification = new firebase.notifications.Notification()
    .setNotificationId(identifier)
    .setTitle(title)
    .setBody(body)
    .setData(userInfo)
    .setSound('notification.wav')
    .android.setAutoCancel(true)
    .android.setPriority(firebase.notifications.Android.Priority.Max)
    .android.setChannelId(activitiesChannel ? activitiesChannel.channelId : null);

firebase.notifications().displayNotification(notification);

mahyarr avatar May 29 '18 15:05 mahyarr

My guess is it's to do with the sound. If you change it to default, does it work?

chrisbianca avatar May 29 '18 15:05 chrisbianca

That didn't help either. I commented out all the lines other than setNotificationId, setTitle, and setBody and still the same issue persists.

Im using react-native-onesignal in the same project. Could that be causing the problem?

mahyarr avatar May 29 '18 15:05 mahyarr

Aha, yes, it is more than likely to be that causing you problems as I'd imagine react-native-onesignal is also trying to do something with the messaging listeners that react-native-firebase listens to...

chrisbianca avatar May 29 '18 16:05 chrisbianca

@chrisbianca Yep, that was the problem. I removed react-native-onesignal and now things are back to normal.

Thanks for the help!

mahyarr avatar May 29 '18 16:05 mahyarr

Ok, glad I could help!

chrisbianca avatar May 29 '18 16:05 chrisbianca

We are seeing the same problem but we need to use react-native-onesignal along side react-native-firebase. Is there any way to resolve this?

leethree avatar Aug 14 '18 10:08 leethree

@chrisbianca Thanks a lot, that fixed everything for me, won't have caught it that easily!!! Lifesaver

Osebrian avatar Oct 12 '18 17:10 Osebrian