App Push Token Set
Should be called after retrieval of Device Token
trackAppPushTokenSet(deviceToken: deviceToken)
LocalAppDelegate.Swift
Code:
...
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
Wunderkind.shared.trackAppPushTokenSet(deviceToken: deviceToken)
}
AppPush Opt In
Should be called when the user has enabled AppPush for the application.
Wunderkind.shared.trackAppPushOptIn()
LocalAppDelegate.Swift
Code:
...
UNUserNotificationCenter.current()
.requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
if granted {
Wunderkind.shared.trackAppPushOptIn()
} else {
Wunderkind.shared.trackAppPushOptOut()
}
}
AppPush Opt Out
Should be called when the user has disabled AppPush for the application.
Wunderkind.shared.trackAppPushOptOut()
LocalAppDelegate.Swift
Code:
...
UNUserNotificationCenter.current().getNotificationSettings { settings in
switch settings.authorizationStatus {
case .authorized:
Wunderkind.shared.trackAppPushOptIn()
case .denied:
Wunderkind.shared.trackAppPushOptOut()
default:
break
}
AppPush Delivered
Should be called when the user’s application had an AppPush Delivered to it.
Wunderkind.shared.trackAppPushDelivered(appPush: notification)
LocalAppDelegate.Swift
Code:
...
internal func applicationDidBecomeActive(_ application: UIApplication) {
UNUserNotificationCenter.current().getDeliveredNotifications {notifications in
notifications
.filter { $0.request.content.userInfo["wunderkindPayload"] != nil }
.forEach { notification in
Wunderkind.shared.trackAppPushDelivered(appPush: notification)
}
}
}
AppPush Opened
Should be called when the user’s application had an AppPush Opened.
Wunderkind.shared.trackAppPushOpened(appPush: notification)
LocalAppDelegate.Swift
Code:
...
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
UIApplication.shared.applicationIconBadgeNumber -= 1
let notification = response.notification
if let wunderkindPayload = notification.request.content.userInfo["wunderkindPayload"] as? [String: Any] {
handleWunderkindItemIds(payload: wunderkindPayload)
Wunderkind.shared.trackAppPushOpened(appPush: notification)
}
}