Apple Watch: can one Watchkit app communicate with multiple iOS apps?

I would like to write a Watchkit app that can communicate with multiple iPhone apps.

For example, call this Watchkit app "PingPong". All it does is set up the watcher and respond to the request - much like an ICMP ping request. So, when the app sends "PING" to the watch, the PingPong Watchkit app responds with "PONG".

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

Note that the document state is: "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 embedded in the iOS app bundle ... Xcode sets up your WatchKit and WatchKit app targets and adds the necessary files to your iOS project. The package IDs for both purposes are automatically configured based on the package ID of your iOS app. The base IDs for all three packages must match, if you change the iOS app bundle ID, you must update the other package IDs accordingly. " https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/ConfiguringYourXcodeProject.html#//apple_ref/doc/uid/TP40014969-CH2-SW1

This implies that there is a 1 to 1 relationship between iOS extension apps and watchkit apps. Manifestation? Watchkit apps are virtually isolated and not possible. But it doesn't hurt to ask. That's what it is for, right ?: P

thanks Keith :)

+3


source to share


2 answers


In fact, watchOS apps are associated with an iOS app.

In both versions, each watchOS app has two purposes: WatchKit App - contains a storyboard, icons, etc. and the WatchKit extension containing the code.

In watchOS 1 (old WatchKit) + iOS 8, the WatchKit app is installed on the Apple Watch, and both the WatchKit Extension and iOS apps are installed on the user's iPhone.

Alternatively, in watchOS 2 + iOS 9 combination, both the WatchKit App and WatchKit Extension are installed on the Apple Watch user, and the iOS app is the only code and view installed on the iPhone.

Running an iOS app only requires one goal, so it can work without an Apple Watch (starting with the first iPhone OS).



But watchOS apps require WatchKit app and WatchKit Extension to run. In watchOS 1 (old WatchKit), because one is on the iPhone and the other on the Apple Watch, so the apps require a Bluetooth connection between them to work, so you need to carry your iPhone nearby. In watchOS 2, both are on the Apple Watch, so you don't need to be connected to an iPhone or have an iPhone nearby to run apps. You can link them to the WatchConnectivity framework included with the watchOS 2 SDK (in Xcode 7).

So in watchOS 2, apps can run offline, but they're not offline at all. They are installed on the Apple Watch when installed on the iPhone, and they can connect with each other. When you create a new watchOS app, you must include it in the iPhone app when you submit it to iTunes Connect.

NOTE. This makes watchOS apps faster and more reliable.

So, in both versions, each WatchKit app is associated with one extension and one iOS app, so you cannot link one watchOS app to more than one iPhone app, or link an iOS app to multiple WatchKit targets. (The exception is the two targets for watchOS 1 (the old WatchKit) and watchOS 2 (which are the same app at the same time, but in two different versions of the watch operating system).

In conclusion, you cannot link multiple watchOS apps or multiple iOS apps. This is a fact in watchOS 1 and 2 and may change in the future.

+2


source


You can achieve this.

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

The path would be to put all three applications in the same application group. This would allow all three applications to access the same common storage where they could store their information to access other applications.



This feature was used to link App App Watch apps in Watch OS 1 and to link with today's extensions.

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

+2


source







All Articles