简体   繁体   中英

Updating WatchKit app when containing iOS app's data changes

I've been reading the Apple Watch Programming Guide and I made some examples of requesting data from the WatchKit extension to the containing app and getting back the result. But what if I want to communicate in the opposite direction? I mean, let's say I have my iOS app in foreground and I refresh there some data, and then I want the WatchKit app to update its user interface according to its paired iOS app just refreshed data. How could I do this? Should I launch a local notification from the iOS app to the WatchKit app and then request the new data from it, or is there any other (and better) way?

Thanks

To notify Watch App from the iOS application for data changes, you can do so manually by using the Darwin notification center.

More reference here: https://devforums.apple.com/message/1082630#1082630

Darwin notification center: https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/MacOSXNotifcationOv/DarwinNotificationConcepts/DarwinNotificationConcepts.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM