Skip to content

Push token tracking

@objc public static func addPushToken(_ pushToken: String, _ service: PushTokenService)

AffiseAttributionLib/Classes/Affise.swift:34-37.

@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).

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)
}

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)
}

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).