Apple Watch:一个Watchkit应用程序可以与多个iOS应用程序通信吗? [英] Apple Watch: Can one Watchkit App communicate with more than one iOS App?

查看:83
本文介绍了Apple Watch:一个Watchkit应用程序可以与多个iOS应用程序通信吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个可以与多个iPhone应用程序通信的Watchkit应用程序.

I'd like to write a Watchkit App that can communicate with more than one iPhone App.

例如,让我们将此Watchkit应用称为乒乓".它所做的全部工作就是建立一个观察者,并响应一个请求-类似于ICMP ping请求.因此,当应用向手表发送"PING"时,PingPong Watchkit应用会以"PONG"作为响应.

For example, let's call this Watchkit App, "PingPong." All it does is set up an observer, and respond to a request--similar to an ICMP ping request. So, when an App sends a "PING" to the watch, the PingPong Watchkit app responds with "PONG."

如何使多个应用程序都可以使用此功能?换句话说,我想公开这个非常简单的界面,以便不同的应用程序可以使用它.

How can I make this functionality accessible to multiple apps? In other words, I would like to expose this very simple interface, so that different apps can use it.

请注意,文档中指出:您必须具有现有的iOS应用才能创建WatchKit应用.WatchKit应用是作为Xcode项目的单独目标实现的,并在iOS应用的捆绑包中构建和打包... Xcode为您的WatchKit应用程序和WatchKit扩展程序配置目标,并将所需文件添加到您的iOS项目中,这两个新目标的捆绑软件ID会根据您的iOS应用程序的捆绑软件ID自动配置.所有三个捆绑软件的基本ID必须匹配;如果您更改iOS应用的包ID,则必须相应地更新其他包ID." https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/ConfiguringYourXcodeProject.html#//apple_ref/doc/uid/TP40014969-CH2-SW1

Note that the docs state, "You must have an existing iOS app to create a WatchKit app. The WatchKit app is implemented as a separate target of your Xcode project and is built and packaged inside your iOS app’s bundle... Xcode configures the targets for your WatchKit app and WatchKit extension and adds the needed files to your iOS project. The bundle IDs for both new targets are configured automatically, based on the bundle ID of your iOS app. The base IDs for all three bundles must match; if you change your iOS app’s bundle ID, you must update the other bundle IDs accordingly." https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/ConfiguringYourXcodeProject.html#//apple_ref/doc/uid/TP40014969-CH2-SW1

这意味着iOS扩展应用程序和watchkit应用程序之间存在一对一的关系.含义?Watchkit应用程序本质上是沙盒化的,这是不可能的.但是问它不会痛.那就是SO的目的,对不对?:P

This would imply that there's a 1-to-1 relationship between iOS extension apps and watchkit apps. Implication? Watchkit apps are essentially sandboxed, and this is not possible. But it couldn't hurt to ask. That's what SO is for, right? :P

Thx,Keith:)

Thx, Keith :)

推荐答案

您可以实现这一目标.

仅在两个iOS应用程序均由同一开发人员开发的情况下.

BUT only in case both iOS apps are developed by the same developer.

方法是将所有三个应用程序放在同一个应用程序组中.这将允许所有三个应用程序访问一个公共存储,在该公共存储中它们可以存储自己的信息以供其他应用程序访问.

The way to go would be to put all three apps in the same App Group. This would allow all three apps to access one common storage where they could store their information to be accessed by the other apps.

此功能用于Watch OS 1中的iOS App<-> Watch App通信以及与今天的扩展程序通信.

This functionality was used for iOS App <-> Watch App communication in Watch OS 1 and for communicating with today extensions.

您可以在此处找到使用应用程序组的教程: http://www.codingexplorer.com/share-data-your-swift-watchkit-apps-with-app-groups/

You can find a tutorial to using App Groups here: http://www.codingexplorer.com/share-data-in-your-swift-watchkit-apps-with-app-groups/

这篇关于Apple Watch:一个Watchkit应用程序可以与多个iOS应用程序通信吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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