get Token
Retrieves the current FCM token from the server.
Return
The FCM token string, or null if unavailable.
Throws
if retrieval fails.
Android (Kotlin)
lifecycleScope.launch {
try {
val token = AFCore.messaging().getToken()
showMessage("Token: $token")
} catch (t: Throwable) {
showError("Could not fetch token: ${t.message}")
}
}Content copied to clipboard
iOS (Swift)
Task {
do {
let token = try await AFCore.shared.messaging().getToken()
self.showMessage("Token: \\(token ?? "none")")
} catch {
self.showError("Could not fetch token: \\(error.localizedDescription)")
}
}Content copied to clipboard