Kodeco Forums

iOS 10 Screencast: Manipulating Push Notifications with Service Extensions

Discover how to use the new notification service extension point which has the ability to intercept push notifications before they're delivered to the user.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4976-ios-10-manipulating-push-notifications-with-service-extensions

Hi Sam, I’m trying to implement the notification service extension but somehow my didReceive method is not called. I have included mutable-content:1 in my payload. What could the problem be?
Thank you!

Hi Sam,

Thank you for great tutorials, I was wondering is it possible to update device id in pusher through code? if I have device ID’s of all the devices which has my app installed and I am trying to send notification to specific device.

Hey Sam,

Where did you get the Pusher app from?

@micpringle: it’s available on GitHub, or installable via homebrew:

@harsh08: I don’t think it is in the macOS app, but you can use NWPusher as a framework in your own app. It wouldn’t be difficult to write an app that does what you want. Check out the above linked GitHub page for more details.

@billhanyu: Sorry about the delay - and now that I’m replying I don’t think it’ll be any help anyway. I don’t have any ideas, no. Hopefully you’ve solved it by now anyway! :blush:

sam

Hi, I have followed the template and everything works nice and thank you for that. I’ve seen a lot of them and yours saved me :slight_smile:

I do have a question and I apologize in advance if it’s too obvious…

Can we have actions for REMOTE Push Notifications?

My app currently receives Remote Push Notifications and acts on the click but what I was not able to achieve is have a Remote PN with Actions. Such as “Remind Me Later” and “Dismiss”.

Hi @elkucho

Glad it helped you out.

You can indeed specify custom actions with remote notifications.

  1. In your app, create a notification category (UNUserNotificationCategory) and set up the correct set of actions (UNUserNotificationAction) with each category.
  2. Register these categories with your app on first-launch
  3. Specify the name of the category you registered in the category field of the remote notification payload
  4. Implement the userNotificationCenter(_:didReceive:withCompletionHandler:) method on your UNUserNotificationCenterDelegate to handle each of the actions you specified in your category.

Hope that helps

sam

Hello @samdavies ,

Thank you for the screencast. Are you planning to add any material around testing app extensions ? I am trying to add unit tests to an app extension. And I am not able to find any tutorials around that topic.

Hi @gprasant.

Glad you enjoyed the screencast. I’m not entirely sure what content we’ll be producing on this topic in future, but I’m sure that @jessycatterwaul will be keen to hear your feedback. I’ll pass it on to him.

I’m also not aware of any content that touches on this topic—I suspect it’d be challenging, although I think Xcode handles extensions far better than it did when I produced these screencasts.

Thanks

sam