Created
May 6, 2015 22:23
-
-
Save peerax/4cd2c6803de859f25470 to your computer and use it in GitHub Desktop.
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
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
// Override point for customization after application launch. | |
if application.respondsToSelector("registerUserNotificationSettings:") { | |
let types:UIUserNotificationType = (.Alert | .Badge | .Sound) | |
let settings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil) | |
application.registerUserNotificationSettings(settings) | |
application.registerForRemoteNotifications() | |
} else { | |
// Register for Push Notifications before iOS 8 | |
application.registerForRemoteNotificationTypes(.Alert | .Badge | .Sound) | |
} | |
return true | |
} | |
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { | |
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes) | |
var tokenString = "" | |
println("tokenString: \(deviceToken)") | |
for var i = 0; i < deviceToken.length; i++ { | |
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]]) | |
} | |
println("tokenString: \(tokenString)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment