Page MenuHomePhabricator

Add Notification Service Extension to populate push notification content
Closed, ResolvedPublic

Description

We need to set up a Notification Service Extension to pull from the Notifications API and determine the notification content to display. The fetching and model code can be shared from the data controller created in https://phabricator.wikimedia.org/T287298.

Initial thoughts for pulling content are:

  • Fetch all unread global notifications from the Notifications API via https://www.mediawiki.org/w/api.php?action=query&meta=notifications&notwikis=*&notprop=list&notfilter=!read&notnotifiertype=push
  • Filter out any unread notifications that whose timestamp is > 10 minutes ago (asked PI and they said this was reasonable).
  • Filter out any notification types that the user does not have flagged in the type settings screen (https://phabricator.wikimedia.org/T288688). We could do this via the read API or share these settings via persistence in the app container. (Test first to confirm this is needed - notifications API may already filter this out server-side). Confirmed this is not needed - thanks notifications do not come through if user has push thank preferences column unchecked.
  • Filter out any notifications that have already been displayed to the user. This means we persist an ongoing list of [wiki+notificationIDs] in the app container once we display to the user, and check against that the next time we're determining notification content here.

From here, there are multiple ways we need to be able to construct this notification content:

  • Combination of multiple notifications (2 talk page messages, 3 edit reverts, etc.) - Will say "New activity on Wikipedia" (see https://phabricator.wikimedia.org/T288773), "Push Notification Content" section.
  • Combination of multiple notifications of the same type (2 talk page messages). - I am bundling talk page messages if they are on the same talk page, per Figma mocks. For other situations (mixed talk page messages, multiple thanks, etc.) I am showing "New activity on Wikipedia" text.
  • Content of a single notification of a recognized type. We also need to do any extra fetching here to populate rich detail IF we choose to support rich notifications (page summary, article image, edit summary, etc). Showing default notification text from the API here (https://phabricator.wikimedia.org/T287033)
  • Content of a single notification of an unrecognized type (maybe it's a future type or something). We need to show default information. (This is defined in subtask https://phabricator.wikimedia.org/T287033).
  • Edge case where the API indicates that there is no new notifications. Could be a hiccup between the type subscriptions, the service delay, etc. (This is defined in subtask https://phabricator.wikimedia.org/T285353).
  • Content if there was a notifications API fetch failure or timeout (This is defined in subtask https://phabricator.wikimedia.org/T285353).

Sidenotes/Questions

  • Apple documentation says to use localizedUserNotificationString(forKey:arguments:) instead of NSLocalizedString when modifying notification content (https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent) - sync update: We aren't going to worry about this extreme edge case.
  • One way to handle potential push service versioning is to fall back to the default content in step 4 if the original push content displays something other than "checkEchoV1".
  • I don't think it would be hard to set thread identifiers here based on notification type for grouping. Just a bonus we can consider in this task.

Dependencies

https://phabricator.wikimedia.org/T287298 (for fetching push notification content)

Related

https://phabricator.wikimedia.org/T288773

QA Testing Notes

Please test against Figma Lock screen mocks here:

https://www.figma.com/file/cedgOU5CyOR0UVqtjDOvzE/iOS-Notifications?node-id=549%3A1750

Note we are not doing any long press functionality for v1, so this is purely for testing against the mocks titled "Lock screen notfiications:"

Event Timeline

LGoto triaged this task as Medium priority.Jul 26 2021, 6:42 PM

Notes from engineering sync:

For notification ID persisting (step 4 in the first list above), we may be able to persist full notification objects instead, then upon tapping into the app have the app extract those objects and add to Core Data. This might prevent some duplicate fetching, one from the service extension and another from the app notification center.

@cmadeo This is blocked on any thoughts you have for coalesced push notification content:

  1. Combination of multiple notifications ("You have 2 talk page messages, 3 edit reverts...", etc.)
  2. Combination of multiple notifications of the same type ("You have 2 talk page messages").

Because of the nature of the way we populate push notification content, we'll need to handle the case of populating content for a single push notification that actually represents multiple notifications. Do you a particular way we should construct this copy? Happy to answer any questions you may have!

@Tsevener My preference would be 2 (bundling notifications of the same type), this way we can eventually push people to the right tab in the notifications view.

For the multiple notifications notification, could we use the same copy as the 'no data' notification: "New activity on Wikipedia"?

@cmadeo good point re: pushing to the right tab. Yeah, we should be able to detect when multiple notifications are the same type and go with something like copy 2, and deep link to the right tab. We can send you copy particulars when we reach this point in coding, might be unnecessary to define everything up front right now.

For the multiple notifications notification, could we use the same copy as the 'no data' notification: "New activity on Wikipedia"?

Yep, we can do that.

Cool! Sounds good @Tsevener. If you want to start a 'needed copy' ticket I'm happy to build off of it or build out strings as needed. Also happy to make that ticket myself if it's easier/better!

Tsevener renamed this task from Add Notification Service Extension to populate push notification content to Add Notification Service Extension to populate push notification content, on tap push to Notification Center.Sep 10 2021, 3:04 AM
Tsevener updated the task description. (Show Details)
Tsevener renamed this task from Add Notification Service Extension to populate push notification content, on tap push to Notification Center to Add Notification Service Extension to populate push notification content.Sep 10 2021, 1:30 PM
Tsevener updated the task description. (Show Details)
Dmantena subscribed.

The target iOS version for this extension was previously accidentally set to iOS 14.5, but has now been corrected to our proper minimum supported version of iOS 13: https://github.com/wikimedia/wikipedia-ios/pull/4118. We need to QA this update on an iOS 13 device to confirm that push notifications are received by those devices. This should be available to test in the next TestFlight beta (6.9.0 (1886)).

Looking good to me across many builds and tested on this one for release 6.9.0 (1910)

JMinor claimed this task.