iOS 10 Rich Notifications Integration

With the new iOS 10 you can attach a static or animated (gif) image, or even a video to push notifications. It will be displayed right in the notification when the user force-taps it.

Here's an example:

iOS 10 rich notifications is action!

iOS 10 rich notifications is action!

You can see it in action right now!

Install Pushwoosh Demo App from the App Store. Scan the QR code of Pushwoosh Demo App in your Pushwoosh Account and go to the Step 4.

Enabling this functionality is very simple, with very little coding involved. Let's do it!

1. Creating Notification Service Extension

First create a Notification Service Extension. This extension downloads the content that will be shown to the user.

Add new target to your project (File->New->Target) and create Notification Service Extension.

Creating Notification Service Extension

Creating Notification Service Extension

Make sure you embed your new extension in your app!

Select your app to embed the extension

Select your app to embed the extension

Notification Service Extension has a separate Apple App ID and Provisioning profile!

Note that notification extension has its own Bundle Id (ex: com.pushwoosh.pushon.NotificationService) as well as its own Apple App ID and Provisioning profile which must be setup in Apple Developer Portal separately.

Architectures

Make sure Notification Service Extension supports Standard architectures (armv7, arm64) (${ExtensionTarget} -> Build Settings -> Architectures).

2. Notification Service Extension Code

The code is available in our Samples at GitHub:
Objective-C, Swift

Just Copy & Paste it to your extension. The code downloads the attachment and calls the notification content handler.

3. Allowing non-secure attachment URL's

Notification Service Extension is a separate binary and has its own Info.plist file.
Starting with iOS9 release to download the content from non-https URL (ex: http://) you have to add App Transport Security Settings with Allow Arbitrary Loads flag set to YES to extension's Info.plist file.

Info.plist

Info.plist

4. Sending Rich Notification

In order to send a rich notification just specify the file's URL in the "iOS10+ Media attachment" field

Woosh! Force-tap the notification and you are all done!

Amazing, isn't it!

Amazing, isn't it!

iOS 10 Rich Notifications Integration