We develop a shared grocery shopping list for iOS, iPadOS and also watchOS. Users can share shopping lists between each other and the lists get automatically synced.
The user can go shopping using our watchOS app alone, as it is an independent watch app. While shopping, connectivity issues are very common, since in retail stores a reliable internet connection is very rare. This leads to the problem that sometimes changes to the shopping list won’t get synced back to our servers.
At some point after the shopping is done, we need to the sync local changes done to the shopping list back to the server. Since the app will most likely be in the background again as the user leaves the retail store, this sync needs to happen in the background (when we have a stable internet connection again). The API for this sync is a simple PUT request with a json body to send.
What frameworks / APIs should we use for this?
Firstly I wanted to use WKURLSessionRefreshBackgroundTasks. But according to this lasts year session at 09: 32 from WWDC20, no networking is allowed for this. Although, if I debug the app, the call completes. So I am confused right now. Can we perform a simple PUT request in the WKExtensionDelegate handle(:Set<WKRefreshBackgroundTask>)?
Also a lot of documentation is pointing me to use BackgroundURLSessions for doing networking in the background (also this session here from WWDC21). But BackgroundURLSessions only support download- or upload tasks. Simple dataTasks are not supported in background sessions (see here). So this is no option either...
What should I do here?
Thank you
Topic:
App & System Services
SubTopic:
General
Tags:
WatchKit
Background Tasks
wwdc21-10003
CFNetwork