This document details how to use the APIs provided by the AEPMessaging framework for tracking and displaying push notifications.
For more in-depth information about the Messaging extension, visit the official SDK documentation for Adobe Journey Optimizer Messaging extension.
Add the following code to the application(_: didRegisterForRemoteNotificationsWithDeviceToken:)
method in the AppDelegate
:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
MobileCore.setPushIdentifier(deviceToken)
}
The interface for handling notifications and their related actions is the UNUserNotificationCenterDelegate
protocol. For help implementing this, refer to the Apple documentation for UNUserNotificationCenterDelegate.
Once you have designated a delegate for the UNNotificationCenter, handle push notification responses in the userNotificationCenter(_:didReceive:withCompletionHandler:) method in the UNUserNotificationCenterDelegate
.
func userNotificationCenter(_: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
Messaging.handleNotificationResponse(response)
// always call the completion handler
completionHandler()
}
Note: This API method will automatically handle click behavior defined for the push notification.
Implement the callback in handleNotificationResponse
API to read PushTrackingStatus enum representing tracking status of the push notification.
Messaging.handleNotificationResponse(response) { trackingStatus in
// handle the different values of trackingStatus
}