Skip to content

Instantly share code, notes, and snippets.

@brunojppb
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunojppb/03a9c088a5ba821c37f9 to your computer and use it in GitHub Desktop.
Save brunojppb/03a9c088a5ba821c37f9 to your computer and use it in GitHub Desktop.
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