Update our current Settings > Notifications subpage.
- Add primary toggle to enable and disable push notifications
- Add per notification type toggles
- Add educational cell
- Add edge case handling (permissions denied, subscription failed, API read/write calls for types toggles failed.
Why are we doing this?
As we begin to support contribution notifications through the iOS app, we need a place for contributors to opt into and out of specific notification types.
Feature job story
As an existing editor I need a way to opt into and out of notifications on my iOS device.
|Logged out||Logged in - Settings||Logged in - Settings > Push Notifications (off)||Logged in - Settings > Push Notifications (on)|
- No settings related to notifications are shown when a user is logged out
- On log in there are two notifications related settings
- Type subscription (shared with web) is available under Settings > Account > Notification subscriptions
- Push notifications subscriptions are available under Settings > Push notifications
For error states please see https://phabricator.wikimedia.org/T288773
Note: To keep track of device token subscription success/failure, I think we will need to keep a subscription boolean flag in UserDefaults.
- 1. Show single primary toggle OFF if OS permissions have not been attempted and the subscription flag is false. Hide individual types toggles in this state.
- 2. When toggled on, prompt for permissions and subscribe device token (subscription call work is already done in https://phabricator.wikimedia.org/T287305). Persist subscription success in UserDefaults flag. Note, we need to be prepared to wait for device token to come in after the user enables permissions. Some devices seem to set one immediately after registration in didFinishLaunching, and others seem to wait for permissions to be enabled first.
- 3. When permissions and subscription succeeds in previous step, pull types preference flags from API (https://www.mediawiki.org/wiki/API:Userinfo). If that succeeds, show types toggles with ON/OFF states according to API. If that fails, show popup error (https://phabricator.wikimedia.org/T288773).
- 4. When permissions from step 2 are denied, display cell that sends user to OS Settings. (https://phabricator.wikimedia.org/T288773).
- 5. When screen is first pushed, check permissions, subscribed flag, and individual types preferences from the API and be sure UI reflects accordingly.
- 6. When device is foregrounded, recheck permissions and update state accordingly in case they changed their permissions in the background.
- 7. When toggling a type toggle: make write preference flags API call (https://www.mediawiki.org/wiki/API:Options). Because global preferences API stuff didn't pan out, we need to make this call for every app preferred language, plus wikidata and commons. If call to update fails, show error prompt and flip toggle back to previous state (https://phabricator.wikimedia.org/T288773)
- 8. If the user adds new app preferred languages, make write preference flags API call on the new language wikis so they match preferences on old app languages. If this fails...try again later. No strong opinions from Product on when to try again later, consider other exponential back off methods in the app for this (reading lists, etc).
- 9. Upon logout, behind the scenes unsubscribe device token from push.
- 10. Privacy bonus: we could listen for their OS permissions (check on foreground), and proactively subscribe or unsubscribe their device token if permissions change to one of these states. (TBD on if this is a must, it adds many opportunities for bugs).
Other things to do:
- 11. There's an explore feed card that could cause complications. Handle them here or break off into another task.
- 12. Disable current news notification code for now, there is a separate task (https://phabricator.wikimedia.org/T287307) to add back in and test that it still works.
- 13. Heavily test and optimize this screen for accessibility.
Notification Type > API associated value for reading and updating
Talk page message > echo-subscriptions-push-edit-user-talk
Thanks > echo-subscriptions-push-edit-thank
Talk page subscription > echo-subscriptions-push-dt-subscription
Translations > echo-subscriptions-push-cx
Mention > echo-subscriptions-push-mention
Failed mention > echo-subscriptions-push-mention-failure
Successful mention > echo-subscriptions-push-mention-success
Page link > echo-subscriptions-push-article-linked
Connection with Wikidata > echo-subscriptions-push-wikibase-action
Failed login attempts > echo-subscriptions-push-login-fail
Login from an unfamiliar device > echo-subscriptions-push-login-success
Page review > echo-subscriptions-push-page-review
User rights change > echo-subscriptions-push-user-rights
Edit revert > echo-subscriptions-push-reverted
Email from other user > echo-subscriptions-push-emailuser
Edit milestone > echo-subscriptions-push-thank-you-edit