Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashaam/b77f1f1072b3048765eace4a0fdbbd1f to your computer and use it in GitHub Desktop.
Save hashaam/b77f1f1072b3048765eace4a0fdbbd1f to your computer and use it in GitHub Desktop.
Get device token for remote push notifications in Swift
// https://hashaam.com/2017/07/22/get-device-token-for-remote-push-notifications-in-swift-3/
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}
let token = tokenParts.joined()
// process token
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment