与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