简体   繁体   中英

iOS Parse deviceToken issues

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?

要获取设备推送令牌,您的应用必须支持推送通知,这可以通过在会员中心注册用于该应用的应用ID并在xcode中为该应用的同一应用ID使用配置文件来确保

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM