ios - 我可以从 iOS App 切换到 Apple Watch 吗?

标签 ios watchkit

我知道您可以从 Watch 切换到 iOS 应用程序,但我有一个用例,我想以相反的方式执行此操作。

用户可以使用比 watch 更复杂的 UI 在手机上创建一组规则,然后切换到 watch (故意使用类似“发送到 watch ”按钮的东西)以进行监控在接下来的 30 分钟左右,他们的设置结果会定期在 watch 上显示。

这可能吗?如果可以,你是怎么做到的?

最佳答案

无法从 iPhone 直接使用 Handoff 到 Apple Watch,因为 watchOS 没有任何 UI 或代码来显示来自 iPhone 的 Handoff 应用。

要获得类似的效果,您可以执行以下操作之一:

1- 您可以简单地告诉用户打开 Watch 应用程序。如果用户打开它,它可以连接到 iOS 应用程序以接收 Handoff 数据。

2- 您可以通过 WatchConnectivity 或 iCloud 将数据保存到 Apple Watch。然后,只要用户打开 Watch 应用程序,它就可以从 iCloud 或 WatchConnectivity 接收数据,无论是一分钟后还是一周后。

Note

You need to check whether the app is installed, or if there is a paired Apple Watch first:

swift

import WatchConnectivity

if WCSession.isSupported(){
    if WCSession.defaultSession().watchAppInstalled{
        //...
    }
}

objective-C

#import <WatchConnectivity/WatchConnectivity.h>

if ([WCSession isSupported]){
    if ([WCSession defaultSession].watchAppInstalled){
        //...
    }
}

关于ios - 我可以从 iOS App 切换到 Apple Watch 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30336458/

相关文章:

iphone - 如何为开发配置我的 iOS 设备?

ios - containerURLForSecurityApplicationGroupIdentifier : gives different results on iPhone and Watch simulator

ios - 与 WatchOS 共享 Realm 数据

swift - 等待 openParentApplication 回调完成

swift - 为什么我不能在 Apple Watch 的接口(interface) Controller 之间发送数据?

ios - 为什么第一次加载不正确但刷新后正确加载?

ios - 如何在 Watchkit 中的 GlanceController 和 InterfaceController 之间进行通信?

iphone - 解码图像属性中的 GPS 坐标

ios - 解析 Class 类型的可变参数列表

objective-c - 在我的 WatchKit 扩展中引用 Objective c 类(swift)