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

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

问题描述

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

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

例如,我们将此 Watchkit 应用称为PingPong".它所做的只是设置一个观察者,并响应一个请求——类似于 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

谢谢,基思 :)

推荐答案

你可以做到这一点.

但前提是两个 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.

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

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-in-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天全站免登陆