0

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?

rici
  • 234,347
  • 28
  • 237
  • 341
jovannypcg
  • 205
  • 3
  • 11

1 Answers1

0

To get device push token your app must support push notification, which will be ensured by registering the app id used for the app in member center and using the provisioning profile for the same app id for the app in xcode

Aanabidden
  • 375
  • 6
  • 18