與SWIFT 3.1爲什麼我沒有收到我的iPhone的任何通知?
下面就Xcode8.3運行,這是我在AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound, .badge], completionHandler: { granted, error in
if granted {
print("OK!")
}
else {
print("No!")
}
})
application.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print("==== didReceiveRemoteNotification ====")
print(userInfo)
}
代碼我使用節點APNS推送通知我的應用程序,我可以從我的調試領域有消息在Xcode中。
==== didReceiveRemoteNotification ====
[AnyHashable("id"): 123, AnyHashable("aps"): {
alert = "Hello World \U270c";
badge = 3;
}]
但是,我沒有收到我的iPhone上的任何通知。
難道我失去了一些東西?
可能重複[蘋果推送通知不生產](http://stackoverflow.com/questions/15595720/apple-push-notification-not-working-in-production) – iphonic
你不需要代碼將設備標識符上傳到您的服務位置? – Alistra
也許是因爲你的應用程序是'foreground'?推僅表現如果是'off'或'background' – JuicyFruit