iOS Message Delivery Tracking

How to add the Notification Service Extension to your iOS native app to track message delivery

There is an API method in Pushwoosh that tracks the delivery of push notifications. iOS apps do not support this method out of the box as push notifications in iOS are handled by the OS, not by Pushwoosh SDK. However, you can implement delivery tracking by adding the Pushwoosh Notification Service Extension for push delivery tracking to your project. Here you'll find the steps to implement Message Delivery Tracking for iOS apps.

Available on iOS 10.0 and later

1. Add Notification Service Extension

1.1. In Xcode, Select File > New > Target...

1.2. Select Notification Service Extansion and press Next.

1.3 Enter the product name and press Finish.

Do not select Activate on the dialog that is shown after pressing Finish.

Press Cancel on the Activate scheme prompt.

By canceling, you are keeping Xcode debugging your app, instead of the extension you just created. If you activated by accident, you can switch back to debug your app within Xcode.

2. Add code for traking message delivery events

2.1 Add the following code to your NotificationService.m file:

#import "PWNotificationExtensionManager.h"
@interface NotificationService : UNNotificationServiceExtension
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
[[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request contentHandler:contentHandler];
}
- (void)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.
}
@end

2.2 Add Pushwoosh_APPID to your Notification Service Extension info.plist.

<key>Pushwoosh_APPID</key>
<string>XXXXX-XXXXX</string>

3. Debug Notification Service Extension

3.1 Choose your main target in Xcode and run your app.

3.2 In the top tab bar, choose Debug > Attach to Process by PID or Name...

3.3 Enter your Notification Service Extension name and press Attach.

3.4 Send a Notification with key-value parameter "mutable-content": 1

"aps": {
"mutable-content": 1,
}

4. Track messages delivery

When sending a message, make sure to add the "mutable-content":1 custom data to your push payload.

For API requests, add the "mutable-content":1 parameter to your request body:

Example
"aps": {
"mutable-content": 1
}

If you miss the "mutable-content":1 param in your push payload, the message delivery won't be tracked.