mutualmobile / MMWormhole

Message passing between iOS apps and extensions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to call a method from parent app?

giacomobartoli opened this issue · comments

I want to call a method (which is inside a controller into the main app) directly from applewatch.
I mean..I click a button on the applewatch and the app on the iPhone starts do something.
Is this possible using MMWormhole?

Thanks

You must make sure the iPhone app is still running when click the button on watch. Otherwise the darwin notification won't be delivered to iPhone app. If your app is in foreground or running in background(playing music, voip or something else which won't be suspend by iOS)

@wizzardchao is correct. I'll elaborate a bit.

If your iPhone app is already running in the background, and you know it is because of something like a background audio or location tracking event, you can just use MMWormhole however you want to and the message will be delivered on the phone. Yay! That's the easy way.

The hard part comes in if you don't know the iPhone app is already running.

In that scenario, you can use the openParentApplication method on WatchKit (watchOS 1), or the WatchConnectivity frameworks' sendMessage API on watchOS 2.

If you want to use the sendMessage API on watchOS 2, we will be providing support for that in MMWormhole 1.3.0 which should ship in the next few days. Check out the MMWormholeSessionMessageTransiting class, and the MMWormholeTransitingTypeSessionMessage for that support.