Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notifications [nfc]: Split
listen
into listenAndroid
and `listenI…
…OS`. In an upcoming commit, we'll abandon `react-native-notifications` (which we'd only been using on iOS) in favor of PushNotificationIOS, provided by React Native (and then we'll take that same code from react-native-community, where it's maintained now). Once we've switched to PushNotificationIOS, none of the events we can listen to on iOS will match the Android events' names. That matching was pointed out in 4008643: """ And the names we use over the `DeviceEventEmitter` channel on Android are chosen to match the names the Wix library offers on its own event source... """ That meant that there were a few possible cases where we could call `this.listen` and pass a single name that wasn't conditioned on the platform. We took advantage of that possibility in one or two places, but we'll no longer be able to, unless we change the Android names to match these (keep reading for one reason not to do this). I'm happy to now have the `PushNotificationEventName` type from PushNotificationIOS (whether from RN or RNC) so we don't accidentally listen for events on iOS that won't be emitted. I'm optimistic that PushNotificationIOS may eventually have types that associate those names with the iOS-specific data shapes that are passed to their corresponding listeners. E.g., if I'm listening for the 'notification' event, my listener must only accept a PushNotificationIOS object. If such types are eventually provided, we'll want to use them -- but keep them away from Android codepaths. Having `this.listenIOS` and `this.listenAndroid` be separate, as well as keeping the events' names in different namespaces, will help with that. One gain from 8ee1793 is easily preserved: these helper functions still ensure that the appropriate functions are called to remove the listeners on `unlistenAll`.
- Loading branch information