iOS Enterprise Push

Enable support for encrypted messages and delivery receipts

Delivery receipts will allow you to confirm when a push notification has been delivered to a device. This allows you to more accurately measure delivery and fallback to other channels.

👍

Enterprise Push Package

The delivery receipts feature is part of the Xtremepush Enterprise Push package, which is a paid feature. Please review our dedicated guide for more details.

📘

Minimum SDK version

This feature is only available in Xtremepush iOS SDK versions starting from v4.1.8.

iOS push delivery receipts require the use of a service extension. This will need to be set up first and then delivery receipts can be enabled.

Setting up your service extension

First, follow the guide for iOS rich media notifications for the steps on Creating a service extension and Setting up the service extension. Next, there are additional steps to complete against the notification extension.

The Xtremepush SDK uses App Groups capability to share receipt data between the main target and notification extension. Xtremepush uses a custom App Group, so even if you already use you own group, you still need to create a group dedicated for Xtremepush.

Here's how to set it up:

  • Register a new App Group on the Apple Developer portal. Use group.YOUR_BUNDLE_IDENTIFIER.xtremepush.suit as the group identifier format.

  • Select the App Groups capability and associate this group with both main app ID and notification extension ID.

📘

A common issue in integrating the service extension is that the app group is only associated with a the app ID.

📘

Invalidated provisioning profile

These steps will invalidate your existing provisioning profile for any schemas you use in your project. You can regenerate them in the Apple Developer portal resources list.

  • Open Xcode and add the App Groups capability to both main target and notification service target:

Set up your notification service extension as shown in code below. If you have already iOS rich media notifications, then you will already have setup a similar extension.

import XPush

class NotificationService: UNNotificationServiceExtension {

    var token: String?

    override init() {
        super.init()
        
        XPush.setDeliveryReceiptsEnabled(true)
        XPush.setAppKey(<#your app key#>)
      	XPush.enableAppGroups("group.YOUR_BUNDLE_IDENTIFIER.xtremepush.suit")
    }
  
    override func didReceive(_ request: UNNotificationRequest,
                             withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.token = XPush.didReceive(request, withContentHandler: contentHandler)
    }

    override func serviceExtensionTimeWillExpire() {
        XPush.serviceExtensionTimeWillExpire(with: token)
    }

}
#import <XPush/XPush.h>

@interface NotificationService ()

@property (nonatomic) NSString* token;

@end

@implementation NotificationService
  
  - (instancetype) init {
    self = [super init];
    if (!self) return nil;

    [XPush setDeliveryReceiptsEnabled:YES];
    [XPush setAppKey:<#your app key#>];
  	[XPush enableAppGroups:@"group.YOUR_BUNDLE_IDENTIFIER.xtremepush.suit"];

    return self;
}

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request 
                   withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.token = [XPush didReceiveNotificationRequest:request
                                   withContentHandler:contentHandler];
}

- (void)serviceExtensionTimeWillExpire {
    [XPush serviceExtensionTimeWillExpireWith:self.token];
}

@end

Now that you have added the notification service extension you are ready to enable delivery receipts back in your

Enable delivery receipts

In the standard integration of the iOS SDK, delivery receipts are switched off. To send delivery receipts to Xtremepush, add the following code when configuring Xtremepush:

XPush.setDeliveryReceiptsEnabled(true)
XPush.enableAppGroups("group.YOUR_BUNDLE_IDENTIFIER.xtremepush.suit")
[XPush setDeliveryReceiptsEnabled:YES];
[XPush enableAppGroups:@"group.YOUR_BUNDLE_IDENTIFIER.xtremepush.suit"];

If you want to send delivery receipts to a custom endpoint, you would include a second param, which will be the URL you are sending to. If you set a custom endpoint for delivery receipts, the delivery receipts will not be sent to Xtremepush.

XPush.setDeliveryReceiptsEnabled(true, customReportingEndpoint: "YOUR_URL");
[XPush setDeliveryReceiptsEnabled:isEnabled customReportingEndpoint:@"YOUR_URL"];

Enable encrypted messages

To enable encrypted push messages after adding the notification service extension, add the following code when configuring Xtremepush:

XPush.enableEncryptedPush(true)
[XPush enableEncryptedPush];