invertase / react-native-notifee

Moved to https://github.com/invertase/notifee
https://invertase.io/blog/open-sourcing-notifee
Other
465 stars 31 forks source link

[iOS] Should background events work with the Notifee Service Extension? #356

Closed meenie closed 3 years ago

meenie commented 3 years ago

Greetings,

I've got the service extension working reliably now, but it seems the notifee.onBackgroundEvent() handler is not being called when the iOS app is in a kill state or just simply in the background. Should those events, i.e. DELIVERED be coming through when using the Notifee service extension?

helenaford commented 3 years ago

Hi, thank you for your question - glad to hear you've got it working reliably

The delivered event will be handled by RNFB (firebase.messaging().setBackgroundMessageHandler) but we could change this to be only handled by notifee? Technically it's still a remote notification. It's on our roadmap to handle a remote notification with notifee handlers.

For all other events, it's handled by notifee.

If you didn't have RNFB installed, it would be handled by notifee. Hope that helps.

meenie commented 3 years ago

Hi @helenaford,

Ahhhhh, okay, ya, I do have RNFB installed. I have some code in that callback that skips any iOS events in there because the Notifee service extension was taking care of showing the notification and then 10 seconds later it was showing again because the same message comes through to the javascript side in the firebase.messaging().setBackgroundMessageHandler() callback.

If you could normalize all of those events and have them go into the notifee.onBackgroundEvent(), that would be ideal. For now, I will put in an exception for iOS in the RNFB background handler.

Thanks!

helenaford commented 3 years ago

@meenie thanks for the insights - definitely can see how we can simplify these events. and yeah, the reason why there's an 8 - 10 second delay to the setBackgroundMessageHandler is intentional in RNFB to ensure js has loaded before events are sent.

mikehardy commented 3 years ago

For what it's worth, I believe with a recent PR (https://github.com/invertase/react-native-firebase/pull/5547) the 8-10 second delay is no longer a thing! Now the iOS app does a lock wait in native code and uses the call to setBackgroundMessageHandler from JS as a signal to un-cork the events, so it should be processed "as quickly as possible" (read as: time for your JS bundle to load/parse/start). This is quite new (and quite welcome!) - first released react-native-firebase in 12.4.0

helenaford commented 3 years ago

@mikehardy ah amazing, thanks for the clarification on that - good to hear that's no longer needed, a great improvement 😎