Local notification not showing while app is open (iOS 11)
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 How are you trying to show the local notification? Do you have a code snippet?
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);
My guess is it's to do with the sound. If you change it to default, does it work?
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?
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 Yep, that was the problem. I removed react-native-onesignal and now things are back to normal.
Thanks for the help!
Ok, glad I could help!
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?
@chrisbianca Thanks a lot, that fixed everything for me, won't have caught it that easily!!! Lifesaver