简体   繁体   English

如何在手表套件中显示通知,iPhone应用程序已在其中显示通知

[英]How to show notification in watch kit , where iPhone app is already showing the notifications

I have an app which shows notification in iPhone. 我有一个在iPhone中显示通知的应用程序。 Now I am trying to show the same notification in WatchKit or in iWatch. 现在,我试图在WatchKit或iWatch中显示相同的通知。 So do I need to recopy all the functionalities I already did in ViewController and AppDelegate of iPhone app in Watchkit Extension or is there some common interface to notify the watch to show the notification, only UI I need to provide. 因此,我需要重新复制我在Watchkit Extension中的iPhone应用程序的ViewController和AppDelegate中已经完成的所有功能,还是需要一些通用接口来通知手表以显示通知,仅我需要提供UI。

iOS will decide to send notification to apple watch or to iPhone. iOS将决定向Apple Watch或iPhone发送通知。

If your iPhone is active then notification will come to iPhone. 如果您的iPhone处于活动状态,则会向iPhone发出通知。 If your iPhone is locked then notification will come to Apple Watch. 如果您的iPhone已锁定,则通知将到达Apple Watch。

Did you have checked "Include Notification Scene" while adding target of watchkit app? 添加监视工具应用程序的目标时,是否已选中“包括通知场景”?

If yes then you can see notification class and WKUserNotificationInterface static interface in your storyboard. 如果是,那么您可以在情节提要中看到通知类和WKUserNotificationInterface静态接口。

You can also customize notification screen at dynamic interface. 您还可以在动态界面上自定义通知屏幕。

If you want to handle notification then implement below method in screen which will display after click on notification in apple watch. 如果要处理通知,请在屏幕中实施以下方法,在Apple Watch中单击通知后将显示该方法。

override func handleActionWithIdentifier(identifier: String?,
    forRemoteNotification remoteNotification: [NSObject : AnyObject])
{

}

Please look at this link: https://developer.apple.com/library/watchos/documentation/General/Conceptual/WatchKitProgrammingGuide/CustomzingthePushNotificationInterface.html 请查看以下链接: https : //developer.apple.com/library/watchos/documentation/General/Conceptual/WatchKitProgrammingGuide/CustomzingthePushNotificationInterface.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM