Last active
August 29, 2015 14:26
-
-
Save brunojppb/03a9c088a5ba821c37f9 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: NSData) { | |
// Create and Store the device token on local database and send | |
// Token to backend API | |
// 1: | |
// remove "<" and ">" from the string | |
let trimEnds = token.description.stringByTrimmingCharactersInSet(NSCharacterSet(charactersInString: "<>")) | |
// 2: | |
// remove spaces | |
let cleanToken = trimEnds.stringByReplacingOccurrencesOfString(" ", withString: "", options: nil) | |
//Send the cleanToken to your WebServer(network call) | |
} | |
// If the user do not allow push notifications, this method will be called | |
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { | |
NSLog("Failed to get token. Error: %@", error) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment