我需要获取设备令牌。 “允许”和“不允许”选项将提示提示弹出窗口。但是当我使用我的客户帐户时,我的设备令牌方法不会被调用。当我刚使用另一个帐户时,我的方法被调用。他们与苹果开发者帐户或其他人有任何问题。我正在尝试但没有得到适当的解决方案。
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let characterSet: NSCharacterSet = NSCharacterSet(charactersInString: "<>")
let deviceTokenString: String = (deviceToken.description as NSString)
.stringByTrimmingCharactersInSet(characterSet)
.stringByReplacingOccurrencesOfString( " ", withString: "") as String
NSUserDefaults.standardUserDefaults().setObject(deviceTokenString, forKey: "callBackToken")
}