I am trying to retrieve the deviceToken using the next code:
func application(application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let installation = PFInstallation.currentInstallation()
installation.setDeviceTokenFromData(deviceToken)
installation.saveInBackground()
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
var tokenString = ""
for var i = 0; i < deviceToken.length; i++ {
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
}
self.deviceToken = "\(tokenString)"
println("\(tokenString)")
var s = tokenString.hmac(CryptoAlgorithm.MD5, key: "")
}
I noticed some devices are not executing this method. Why does this happen? How can I get the deviceToken using a different method?