1
突然,兩天前我停止接收推送通知給我的iPhone(我每隔5-10分鐘從我的網站發送自動推送通知)。快速獲取設備令牌
我打開了我的Xcode項目並嘗試收到我的設備令牌,以檢查一切是否正常,但不是正在打印。 它要求我在我的設備上啓用推送通知,當我按下「確定」時,沒有任何反應。
的代碼下面,在應用程序委託:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
registerForPushNotifications(application)
return true
}
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
if notificationSettings.types != .None {
application.registerForRemoteNotifications()
}
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
var tokenString = ""
for i in 0..<deviceToken.length {
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
}
print("Device Token:", tokenString)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print("Failed to register:", error)
}
你有沒有做過類似開啓飛行模式或禁用數據連接和wifi? – Gruntcakes
有時標記爲精確重複的問題可能會有非常不同的原因和解決方案。 –