Search code examples
ios9watchkitwatchos-2watchconnectivity

Have both iPhone & watch app start?


I have created a companion Apple Watch app, and want to sync data between the phone and the watch.

Is there a way to get both apps to load at the same time? If I open the iPhone app, the watch app doesn't open, and vice versa.


Solution

  • You can't force a counterpart app to open in the foreground, but it's not necessary for it to be open.

    An app doesn't need to be open before you can transfer context data to it. The system sends that data in the background, even if the counterpart app is not open.

    Once you do open the counterpart app, receivedApplicationContext is called to deliver the waiting data.

    Use the updateApplicationContext:error: method to communicate recent state information to the counterpart. When the counterpart wakes, it can use this information to update its own state.

    You're already using the proper method to sync data between devices, and the transfer works as Apple intended. It's much more efficient to transfer data in the background to be on hand, than to wait for an app to be open before transferring data to it.