WatchKit app extensions need some way to ensure changes are sent to the cloud in a timely manner

Originator:brent
Number:rdar://19028882 Date Originated:19-Nov-2014 03:53 AM
Status:Duplicate/18033548 Resolved:
Product:iPhone SDK Product Version:Xcode-Beta (6C86e)
Classification:Enhancement Reproducible:Always
 
Summary:
When a WatchKit app extension changes local data and then needs to communicate its changes to a cloud service, it has no way to ensure it runs long enough to send these changes, and no way to invoke its containing app to do so on its behalf. This means that WatchKit apps cannot reliably update CloudKit data, making iCloud appear slow, unreliable, or broken to Apple Watch wearers.

Steps to Reproduce:
1. Write an app with a local read-write data store like Core Data.
2. Add two-way sync between the local data store and a cloud database like CloudKit.
3. Add a watch app capable of mutating the data in some fashion which needs to be synced.

Expected Results:
There is some way for the watch app extension to ensure its mutations are uploaded in a timely manner.

Actual Results:
There is no such technique.

Regression:
In most extensions, the extensionContext can be used to invoke openURL:completionHandler: to launch the containing app, which has the ability to delay its closing long enough to upload content. Watch apps, however, do not have an extensionContext and cannot do this.

Notes:
This is less of a problem when downloading changes; a well-written sync process will work fine if it’s terminated in the middle of a download, and even if it isn’t, push notifications (using CloudKit or otherwise) can help keep the local data in sync. But when changes need to be uploaded, aborting an upload in the middle will cause a change in behavior (as other devices won’t see changes when they update themselves), and no server will intervene to launch the containing app.

objective-dave suggests in <https://devforums.apple.com/thread/254553> that extensions should let the containing app handle interacting with the cloud. He admits, however, that watch app extensions cannot invoke the containing app the way that other extensions (such as Today widgets) can. 

A simple solution might be to allow -openURL:completionHandler: or a similar API to be used from a watch app extension. However, I think this is a bit of kludge. It might be better to add an API that allows an extension to launch its containing app in the background, or to allow an app to request that it be launched in the background whenever a file in a shared container it can access changes.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!