I have an iPhone application and added a WatchKitExtension. From the iPhone App I want to pass a String
to the WatchApp which is supposed to change an image on the Watch.
- What I already did was to download the source files and import the
MMWormhole.m
&.h
. They are written in Obj-C and so Xcode automatically bridged them for me. - I also added an app group and activated it for my WatchExtension & my iPhone target
In the tutorial on GitHub it says I have to initialize the wormhole with:
self.wormhole = [[MMWormhole alloc] initWithApplicationGroupIdentifier:@"group.com.mutualmobile.wormhole"
optionalDirectory:@"wormhole"];
...and send a message using:
[self.wormhole passMessageObject:@{@"titleString" : title}
identifier:@"messageIdentifier"];
But I have actually no idea where to put that, I am using Swift in my iPhone application and the WatchExtension.
Can anyone please help me there?
I suppose it depends on different applications, but for one application I put the listeners in the
didFinishLaunchingWithOptions
method of my app delegate in the main iOS app. This was because the user would be using the watch, and they would be relaying information off to the phoneThere were multiple listeners...
And then in a
WKInterfaceController
, I sent a message. Sometimes in an action, sometimes in thewillActivate
method. It really depends on the flow of your appThis can work both ways though, I could have very easily put a listener in my watch which would wait for messages initiated by some Interface Controller on the phone.