0

I have an app opened on my iPhone, I would like to know if there is a way to call remotely a function of this app from my apple-watch (watchOS 3) by simply tapping a button?

The function concerned stores data from the accelerometer. I searched on the Internet. I found a beginning of solution on Stackoverflow but it still remains a bit mysterious for me.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jeff 974
  • 69
  • 1
  • 4

1 Answers1

0

You can transmit information from the watch app to the iOS app using the WCSession APIs. Assuming you have a paired and activated WCSession, from your watch app you can call WCSession.sendMessage:replyHandler:errorHandler and the message will be transmitted straight away to the iOS device. Your foreground iOS app will need to be listening for a message using WCSessionDelegate.session:didReceiveMessage:replyHandler. From there based upon the message received you can invoke your function.

appfigurate
  • 136
  • 1
  • Dear appfigurate, It's a good starting point for further investigation. Thanks a lot for your support. – Jeff 974 Jul 03 '18 at 17:16