Edit in GitHubLog an issue

Push Notification - API reference

This document details how to use the APIs provided by the AEPMessaging framework for tracking and displaying push notifications.

Pre-requisites

Integrate and register AEPMessaging extension in your app.

Sync the push token

To retrieve the push token in iOS, refer to the Apple documentation for registering your app with APNs. Then add the following code to the application(_: didRegisterForRemoteNotificationsWithDeviceToken:) method in the AppDelegate to sync the device's push token with profile in Adobe Experience Platform.

Copied to your clipboard
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
MobileCore.setPushIdentifier(deviceToken)
}

Track push notification interactions

Use handleNotificationResponse API to send push notification interaction data to Adobe Experience Platform.

In iOS, UNUserNotificationCenterDelegate is the interface for processing incoming notifications and responding to notification actions. Once the delegate is implemented, handle push notification responses in userNotificationCenter(_:didReceive:withCompletionHandler:) method.

Copied to your clipboard
func userNotificationCenter(_: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
Messaging.handleNotificationResponse(response, urlHandler: { url in
/// return `true` if the app is handling the url or `false` if the Adobe SDK should handle it
let appHandlesUrl = false
return appHandlesUrl
}, closure: { pushTrackingStatus in
if pushTrackingStatus == .trackingInitiated {
// tracking was successful
} else {
// tracking failed, view the status for more information
}
})
completionHandler()
}

Reading push tracking status

Implement the callback in handleNotificationResponse API to read PushTrackingStatus enum representing tracking status of the push notification.

Copied to your clipboard
Messaging.handleNotificationResponse(response) { trackingStatus in
// handle the different values of trackingStatus
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.