4

We want to add a feature to our app so that users are able to opt-in to being reminded to read important notifications which they might have missed. Here's how we would like it to work:

  1. When a push notification comes in, a Notification Service Extension triggers.
  2. The extension checks to see if it should do any work (we don't want to remind users if they are currently in the app).
  3. If reminding is enabled, the extension attempts to spawn 3 local notifications at 1-minute intervals reminding the user that they have missed important information.
  4. If the user opens the app, all existing local notifications are cleared.
  5. If another notification arrives before the user opens the app, any existing local notifications are cleared and a new set are created.

This works great, except for step #3. I check notification authorization from within the service extension before I do work and am consistently getting .authorized back. However, when I call UNUserNotificationCenter.current.add(_:withCompletionHandler:), the completion handler is invoked with a UNError: Notifications are not allowed for this application.

What's odd is that it works sometimes. For example, I'll get the 2nd notification through and get the reminder for it, but the 1st and 3rd fail. However, this is exceedingly rare (< 5% success rate scheduling local notifications).

Does anyone have any insight into this?

jscs
  • 63,694
  • 13
  • 151
  • 195
Joshua Sullivan
  • 1,073
  • 8
  • 12
  • Hi Joshua, could you find the reasone? I am getting it too. Authorize for local notification but when adding the local notification, getting the exact error message. – abmussani Aug 01 '19 at 12:35
  • I never was able to determine what was going on. We reworked the feature to not use an extension, going instead with multiple pushes. If it’s critical for you, I’d recommend filing a support request with Apple, as there doesn’t seem to be a viable solution in the community. – Joshua Sullivan Aug 01 '19 at 12:49

0 Answers0