如何在独立的 Apple Watch 应用程序中配置推送通知
How to configure push notifications in independent apple watch application
我们正在开发独立的苹果手表应用程序(Watch os 6),我们需要接收推送通知。
那么,我们如何在手表上直接接收推送通知呢?
因为它是一个独立的应用程序,我们没有支持推送通知的苹果 phone 应用程序。
对于独立的 watchOS 应用程序,您必须通过在扩展委托中分别调用 WKExtension.shared().registerForRemoteNotifications()
. Generally, you make this call in the applicationDidFinishLaunching()
delegate method implemented by your extension delegate. After calling to register for remote notifications, you should handle the success or failure by implementing didRegisterForRemoteNotifications(withDeviceToken:)
and didFailToRegisterForRemoteNotificationsWithError(_:)
来注册远程推送通知。
关于推送通知的呈现(根据 Apple 的开发者文档):
To display alerts, play sounds, or perform other user-facing actions, you must also request authorization using the UNUserNotificationCenter class’s requestAuthorization(options:completionHandler:) method. If you do not request and receive authorization for your app’s interactions, the system delivers all remote notifications to your app silently.
我们正在开发独立的苹果手表应用程序(Watch os 6),我们需要接收推送通知。 那么,我们如何在手表上直接接收推送通知呢?
因为它是一个独立的应用程序,我们没有支持推送通知的苹果 phone 应用程序。
对于独立的 watchOS 应用程序,您必须通过在扩展委托中分别调用 WKExtension.shared().registerForRemoteNotifications()
. Generally, you make this call in the applicationDidFinishLaunching()
delegate method implemented by your extension delegate. After calling to register for remote notifications, you should handle the success or failure by implementing didRegisterForRemoteNotifications(withDeviceToken:)
and didFailToRegisterForRemoteNotificationsWithError(_:)
来注册远程推送通知。
关于推送通知的呈现(根据 Apple 的开发者文档):
To display alerts, play sounds, or perform other user-facing actions, you must also request authorization using the UNUserNotificationCenter class’s requestAuthorization(options:completionHandler:) method. If you do not request and receive authorization for your app’s interactions, the system delivers all remote notifications to your app silently.