-2

I want to share data between watch and iphone application display it in glance view , which is the best way to share data Watch Connectivity framework or app groups ? If Watch Connectivity then which method in Watch connectivity is suitable for transfer data between glance view and iphone application?

Himan Dhawan
  • 894
  • 5
  • 23

2 Answers2

1

App group will work only with a watchOS 1.0 app since the watch kit extension and the main iOS both run on the phone, since watchOS 2.0 the extension runs natively on the watch making app groups useless for data transfer since iOS and watchOS app runs on two different devices.

As Sam B pointed out in the comments since watchOS 2.0 the only way to transfer data between iOS and watchOS is the WatchConnectivity framework. This offers you three way to exchange data, is then up to you to choose the one that best fit your app:

  1. updateApplicationContext:error: transfer a dictionary of data between phone and watch. This dictionary is seen like a state of your app and any new transfer will override previously sent ones, its useful if want to exchange background data. Your data is handled by the operating system and delivered when the receiver wakes up.
  2. sendMessage:replyHandler:errorHandler:/sendMessageData:replyHandler:errorHandler: transfer respectively a dictionary and data (NSData) in real time (the receiver must be running), this is especially useful is game app.
  3. transferUserInfo:/transferFile:metadata: transfer respectively a dictionary and a file in the background like method 1 but all transfers are delivered and not overwritten.

For further information you can read Apple Documentation or watch WWDC 2015 session 713.

About your last question method 2 doesn't fit your needs, maybe more 1 than 3, but that's up to you to decide, after watching the video I linked before you should have more clear ideas about what to choose.

Marco Boschi
  • 2,321
  • 1
  • 16
  • 30
-1

WCSession is best way to communicate with ios application its also support background mode transfer from watch to application and application to watch Link

Kandhal Bhutiya
  • 198
  • 1
  • 9