Push token tracking
addPushToken
Section titled “addPushToken”@objc public static func addPushToken(_ pushToken: String, _ service: PushTokenService)— AffiseAttributionLib/Classes/Affise.swift:34-37.
PushTokenService
Section titled “PushTokenService”@objc public enum PushTokenService: Int { case FIREBASE case APPLE}— AffiseAttributionLib/Classes/settings/PushTokenService.swift:4-7. Raw service strings are fms and apns (PushTokenService.swift:8). A converter is available via public static func from(_ service: String?) -> PushTokenService? (PushTokenService.swift:18).
APNs example
Section titled “APNs example”Verbatim:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey: Any]?) -> Bool { // ... UIApplication.shared.registerForRemoteNotifications() return true}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let pushToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined() Affise.addPushToken(pushToken, .APPLE)}Firebase example
Section titled “Firebase example”Verbatim:
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { print("Firebase registration token: \(String(describing: fcmToken))")
// New token generated — unwrap the optional before passing to addPushToken (non-optional String) guard let token = fcmToken else { return } Affise.addPushToken(token, .FIREBASE)}Uninstall / reinstall tracking
Section titled “Uninstall / reinstall tracking”Verbatim:
Affise automaticly track reinstall events by using silent-push technology, to make this feature work, pass push token when it is recreated by user and on you application starts up.
Related ProviderType values: UNINSTALL_TIME, REINSTALL_TIME, PUSHTOKEN, PUSHTOKEN_SERVICE (AffiseAttributionLib/Classes/parameters/ProviderType.swift:33-34; see Device info).