Skip to content

Instantly share code, notes, and snippets.

@3257
Created January 31, 2018 12:38
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 3257/814025bee45bb72a2d9075c565b70abc to your computer and use it in GitHub Desktop.
Save 3257/814025bee45bb72a2d9075c565b70abc to your computer and use it in GitHub Desktop.
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// 1. Convert device token to string
let tokenParts = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}
let token = tokenParts.joined()
// 2. Print device token to use for PNs payloads
print("Device Token: \(token)")
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
// 1. Print out error if PNs registration not successful
print("Failed to register for remote notifications with error: \(error)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment