forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ios notifications: Stop using
react-native-notifications
.
Some (rather rude! yet still disregarded and closed-as-stale) comments [1] on wix/react-native-notifications report that it's a shame to see a decrease in activity from the maintainers, since it's the only viable cross-platform library for RN push notifications. But we don't even use it in a cross-platform way; we uprooted the last of the linking logic on Android in 01b33ad. It also seems strange to have two different libraries doing work to support push notifications on iOS. See also discussion [2]. So, let PushNotificationIOS from react-native take responsibility for what this library has been doing. Then, since *that's* deprecated, an upcoming commit will have us using that same code but from react-native-community, where it's maintained. These were my steps: 1. Use the setup instructions for our version of `react-native-notifications` [3] to tear it down. 2. Use the setup instructions for `PushNotificationIOS` [4] from RN v0.60 to complete our setup. Some parts were missing, whether because we didn't need that functionality before, or it wasn't available in earlier RN versions. 3. Change the bit under the comment "Called when a notification is delivered to a foreground app." to correctly call the completion handler with UNNotificationPresentationOptions instead of UNAuthorizationOptions. N.B.: Also, remove the options that ask it to play a sound and show an alert, as these aren't part of the current behavior. That just leaves updating the badge count. 4. Make tiny, NFC adjustments, mostly to indentation, to smooth the transition to the react-native-community module. 5. Change the call sites to use PushNotificationIOS, and update some types and comments. One part that stands out is the removal of the "consumeBackgroundQueue" hack from c0e2233. Nothing further is necessary, it just works. :) 6. Do various housekeeping things like removing the libdef. 7. On iOS, test that notifications still appear in the closed and background states and that, from either state, they navigate to the corresponding narrow. All works as expected, with one "gotcha": from a cold start, in debug mode, sometimes notifications don't navigate. There's an open issue for this [5], and it seems it doesn't affect release builds. In debug mode, I was able to solve it by disabling "Debug JS Remotely", following one comment there. In any case, `getInitialNotification` is what we've already been using PushNotificationIOS for, for a long time, so this hiccup is not new. 8. On Android, test that notifications appear (regardless of closed/background/foreground state) and navigate to the corresponding narrow. [1]: wix/react-native-notifications#519 (comment) [2]: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/iOS.20push.20notifications/near/825122 [3]: https://github.com/wix/react-native-notifications/blob/882775fb5/docs/installation.md [4]: https://reactnative.dev/docs/0.60/pushnotificationios [5]: react-native-push-notification/ios#24 (comment)
- Loading branch information
1 parent
08ea7d1
commit 3ce528e
Showing
11 changed files
with
113 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.