Created
October 30, 2019 12:40
-
-
Save SergLam/1a3616677468a966170f035c000fae60 to your computer and use it in GitHub Desktop.
Convert device token to string - Swift 5.1
This file contains hidden or 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
import Foundation | |
// IMPORTANT: check APS environment (production or sandbox) in your app .entitlements file | |
extension Data { | |
func hexString() -> String { | |
return self.map{ String(format: "%02.2hhx", $0) }.joined() | |
} | |
} | |
// Usage: | |
// func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
// | |
// let token5 = deviceToken.hexString() | |
// } | |
// Tools for push notifications testing: | |
// https://github.com/onmyway133/PushNotifications | |
// https://github.com/noodlewerk/NWPusher |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment