Configure the Notification Content extension
With the AEPNotificationContent
package now available after following the installation steps, the app and notification content extension must be configured to use it.
App configuration
Ensure the
AppDelegate
implementsUNUserNotificationCenterDelegate
.Copied to your clipboard@mainclass AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {...}In your
AppDelegate
, after the user has granted your app permission to display notifications, create any custom notification actions needed by your app and register a category with identifierAEPNotification
.Copied to your clipboardlet center = UNUserNotificationCenter.current()// ask user for permission to display notificationscenter.requestAuthorization(options: [.badge, .sound, .alert]) { [weak self] granted, _ in// return early if the user does not consentguard granted else { return }center.delegate = self// create a category with desired actions and `AEPNotification` as the identifierlet myCategory = UNNotificationCategory(identifier: "AEPNotification",actions: [],intentIdentifiers: [],options: [.customDismissAction])// register the categoryUNUserNotificationCenter.current().setNotificationCategories([myCategory])// if not done elsewhere, register the app to receive remote notificationsDispatchQueue.main.async {application.registerForRemoteNotifications()}}
Notification Content extension configuration
Update the Info.plist
for your Notification Content extension with the following values:
Key | Type | Value |
---|---|---|
NSExtension.NSExtensionPrincipalClass | String | AEPNotificationContent.AEPNotificationViewController |
NSExtension.NSExtensionAttributes.UNNotificationExtensionUserInteractionEnabled | Boolean | YES |
NSExtension.NSExtensionAttributes.UNNotificationExtensionDefaultContentHidden | Boolean | YES |
NSExtension.NSExtensionAttributes.UNNotificationExtensionCategory | String | AEPNotification |
NSExtension.NSExtensionAttributes.UNNotificationExtensionInitialContentSizeRatio | Number | 0.2 |
Next steps
Use a sample payload to generate a notification in your app by completing the steps in Validate AEPNotificationContent integration.