Last active
March 31, 2018 15:54
-
-
Save meyusufdemirci/99224897a6c00d505f919688b1eba1c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
print("Notification registration is success.") | |
if #available(iOS 10.0, *) { | |
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) | |
print(deviceTokenString) | |
} else { | |
let tokenParts = deviceToken.map { data -> String in | |
return String(format: "%02.2hhx", data) | |
} | |
let deviceTokenString = tokenParts.joined() | |
print(deviceTokenString) | |
} | |
} | |
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { | |
print("Notification registration is fail: \(error.localizedDescription).") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment