如何在手表套件中显示通知,iPhone应用程序已经在其中显示通知 [英] How to show notification in watch kit , where iPhone app is already showing the notifications

查看:143
本文介绍了如何在手表套件中显示通知,iPhone应用程序已经在其中显示通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在iPhone中显示通知的应用程序.现在,我试图在WatchKit或iWatch中显示相同的通知. 因此,我需要重新复制我在Watchkit Extension中已在iPhone应用程序的ViewController和AppDelegate中完成的所有功能,还是有一些通用接口来通知手表以显示通知,只有我需要提供的UI.

I have an app which shows notification in iPhone. Now I am trying to show the same notification in WatchKit or in 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.

推荐答案

iOS将决定向Apple Watch或iPhone发送通知.

iOS will decide to send notification to apple watch or to iPhone.

如果您的iPhone处于活动状态,则会向iPhone发出通知.如果您的iPhone已锁定,则通知将到达Apple Watch.

If your iPhone is active then notification will come to iPhone. If your iPhone is locked then notification will come to Apple Watch.

在添加监视工具应用程序的目标时,您是否选中了包括通知场景"?

Did you have checked "Include Notification Scene" while adding target of watchkit app?

如果是,那么您可以在情节提要中看到通知类和WKUserNotificationInterface静态接口.

If yes then you can see notification class and WKUserNotificationInterface static interface in your storyboard.

您还可以在动态界面上自定义通知屏幕.

You can also customize notification screen at dynamic interface.

如果要处理通知,请在屏幕上实施以下方法,然后在Apple Watch中单击通知后将显示该方法.

If you want to handle notification then implement below method in screen which will display after click on notification in apple watch.

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

}

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

这篇关于如何在手表套件中显示通知,iPhone应用程序已经在其中显示通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆