Push Notifications

The mParticle SDK can be configured to receive, show, and track the results of push notifications from various integrations such as Urban Airship and Mixpanel.

Setup Push Notifications

To be able to send Push Notifications, you will need to generate a TLS certificate from your Apple Developer account and provide the certificate to any partner platform you will be using to send Push Notifications.

Register for Push Notifications

Unlike the Android SDK, mParticle’s iOS SDK does not handle Push Notification Registration. The host application must register for notifications with the Apple Push Notification service (APNs) at the appropriate time in the user experience. Follow Apple’s Push Notification guide to complete APNs Registration.

Display Push Notifications

Provided you are using the iOS SDK’s UIApplicationDelegate proxy, the SDK will automatically listen to the following API invocations and forward them to any mParticle Kits that can display the notifications:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo;

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error;

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)(void))completionHandler;

If you are not using the UIApplicationDelegate proxy, you must manually forward these methods to mParticle.

The UIApplicationDelegate proxy cannot intercept invokations from the UNUserNotificationCenterDelegate introduced in iOS 10. If you use this delegate’s willPresentNotification or didReceiveNotificationResponse, you will need to call the equivalent method in the mParticle SDK as shown below:

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
    [[MParticle sharedInstance] userNotificationCenter:center willPresentNotification:notification];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
    [[MParticle sharedInstance] userNotificationCenter:center didReceiveNotificationResponse:response];
}

Kits

The following Kit integrations can receive Push Notifications:

Push Notifications from any of these partners will be displayed by the relevant kit instance. Note that you will need to upload your APNs Push SSL certificate to any providers you use for Push Notifications. See the docs for each integration for details.

Was this page helpful?