如何在 iWatch 中显示通知? [英] How to show notification in iWatch?

查看:80
本文介绍了如何在 iWatch 中显示通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我想实现一些功能,比如当 iPhone 离 iWatch 有一段距离时,手表应用程序显示带有短信的本地通知

In my app, I want to implement functionality like when iPhone away with some distance from iWatch than watch app show local notification with a text message

推荐答案

如果 Watch 与 Phone 断开连接时你能得到通知就足够了,你可以使用 WatchConnectivity 框架来实现这个.当手表与电话断开连接时,可选的 func sessionReachabilityDidChange(_:) 在手表上被调用.但是,您的 WatchExtension 需要在前台运行或在后台以高优先级运行才能运行此功能.

If it is enough for you to get notified when the Watch gets disconnected from the Phone, you could use the WatchConnectivity framework to achieve this. The optional func sessionReachabilityDidChange(_:) gets called on the Watch when it disconnects from the Phone. However, your WatchExtension needs to be running in the foreground or with high priority in the background for this function to work.

这篇关于如何在 iWatch 中显示通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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