如何将一些消息或字符串从 iPhone 设备传递到配对的 Apple Watch [英] how to pass some message or string from iphone device to paired apple watch

查看:42
本文介绍了如何将一些消息或字符串从 iPhone 设备传递到配对的 Apple Watch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将特定消息或字符串从我的 iPhone 设备传递到配对的 iWatch.我真的很想知道这是如何从开发的角度处理的.是否有任何特定的 WKInterfaceController 方法或 API 可以将信息从 iPhone 传递到 iWatch?

I would like to know how a particular message or string can be passed from my iPhone device to the paired iWatch. I would really like to know how this is handled from development point of view. Is there any particular WKInterfaceController method or API which passes the info from iPhone to iWatch?

我在开发者论坛上读到 openParentApplication:reply: 从 iWatch 和 application:handleWatchKitExtensionRequest:reply 通知 iPhone 应用程序处理 iPhone 上的特定通知请求.但我想要反过来.

I have read on developer forum that openParentApplication:reply: notifies the iPhone application from iWatch and application:handleWatchKitExtensionRequest:reply handles that particular notification request on iPhone. But I want the reverse.

比方说,我有一个带有 UITextField 和 UIButton 的 iPhone 应用程序故事板场景.用户输入你好!"在文本字段上并单击按钮.现在我在同一个项目中有一个带有 iwatch 故事板的手表套件扩展.这个故事板场景有一个WKInterfaceLabel".我想让我的 iPhone 控制器与 WKInterfaceController 交互,以便在 iphone stroyboard 上输入的消息(在本例中为你好!")可以传递给 iWatch 控制器并显示在 iWatch 上.

Lets say, I have an iPhone application storyboard scene with a UITextField and UIButton. User enters "Hello !" on text field and clicks on button. Now I have a watch kit extension within the same project with an iwatch storyboard. This storyboard scene has an "WKInterfaceLabel". I would like to have my iPhone controller interact with WKInterfaceController so that the message entered on iphone stroyboard ("Hello !" in this case) can be passed to the iWatch controller and displayed on the iWatch.

推荐答案

为了从 iPhone 与您的手表通信,您需要使用应用程序组和达尔文通知.您可以使用 MMWormhole(此处提供)来执行此操作.

In order to communicate from iPhone to your watch, you need to use app groups, and darwin notifications. You can use MMWormhole (available here) to do this.

这篇关于如何将一些消息或字符串从 iPhone 设备传递到配对的 Apple Watch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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