Last active
October 9, 2015 06:59
-
-
Save coa00/c6d9991a84e5c9b57515 to your computer and use it in GitHub Desktop.
Swift2.0でdeviceTokenをNSUserDefaultsに保存 ref: http://qiita.com/coa00@github/items/7172665c414cfc913cc0
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, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
// for APNs | |
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge], categories: nil) | |
application.registerUserNotificationSettings(settings) | |
application.registerForRemoteNotifications() | |
// Override point for customization after application launch. | |
return true | |
} | |
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { | |
let ud = NSUserDefaults.standardUserDefaults() | |
ud.setValue(deviceToken.description, forKey: "token") | |
ud.synchronize() | |
} |
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
let token:String = ud.objectForKey("token") as! String; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment