iOS rich notifications integration
Starting with iOS 10, you can attach a static or animated 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 rich notifications is action!

Enabling this functionality is very simple, with very little coding involved. Let’s do it!
1. Creating Notification Service Extension
Section titled “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.

Make sure you embed your new extension in your app!

2. Notification Service Extension code
Section titled “2. Notification Service Extension code”The code downloads the attachment and calls the notification content handler.
Just Copy & Paste it to your extension.
import UserNotificationsimport PushwooshFramework
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { // Pushwoosh ********** PWNotificationExtensionManager.shared().handle(request, contentHandler: contentHandler) // ********************
self.contentHandler = contentHandler bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent { // Modify the notification content here... contentHandler(bestAttemptContent) } }
override func serviceExtensionTimeWillExpire() { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { contentHandler(bestAttemptContent) } }
}
#import "PWNotificationExtensionManager.h"
@interface NotificationService : UNNotificationServiceExtension
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { // Pushwoosh ********** [[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request contentHandler:contentHandler]; //*********************}
@end
3. Allowing non-secure attachment URL’s
Section titled “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.

4. Sending a rich notification
Section titled “4. Sending a 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!

Share your feedback with us
Section titled “Share your feedback with us”Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.