Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

guaranteed delivery for uploads after network reconnect, even if my app is not running

I'm spec-ing an iOS app (which will be built outside of our company) which will upload a user's data entry to a server. If the device is not connected to the Internet, we'd like to save data on the device and upload it when the network is re-connected. (The app will primarily run on iPod Touch devices that will be disconnected most of the time).

If the user unlocks the device and re-opens our app after the network is reconnected, then uploading to the server should be easy because the app is running.

But what if the app is not running, where "not running" can mean one or more of:

  • device was power cycled
  • user has locked the device and it's sitting in his pocket
  • app crashed
  • user exited the app
  • user started using other apps so our app isn't running in the foreground anymore
  • are there other cases?

In the cases above, is there a way (ideally a battery-efficient way) to ensure that local data is uploaded soon after Internet connectivity is restored? Is the answer different depending on which of the cases above caused the app not to be running?

And is there a minimum iOS version the device will need in order to enable some (or all) of the above not-running cases to still upload when the app is not running?

My apologies if these are obvious newbie questions-- I'm not an iOS expert.

like image 921
Justin Grant Avatar asked Sep 01 '12 02:09

Justin Grant


People also ask

What happens when a device is not compliant in Intune?

The result of this default is when Intune detects a device isn't compliant, Intune immediately marks the device as noncompliant. After a device is marked as noncompliance, Azure Active Directory (AD) Conditional Access can block the device.

What one thing can you not do using an AWS Elastic load balancer?

You cannot add or remove availability zones for a Gateway Load Balancer after you create it.

Which load balancer is best suited for HTTP https load balancing traffic?

Application Load Balancer can redirect an incoming request from one URL to another URL. This includes the capability to redirect HTTP requests to HTTPS requests, which allows you to meet your compliance goal of secure browsing, while being able to achieve better search ranking and SSL/TLS score for your site.

Which AWS service is the best choice for publishing messages to subscribers?

Q: What is Amazon Simple Notification Service (Amazon SNS)? It provides developers with a highly scalable, flexible, and cost-effective capability to publish messages from an application and immediately deliver them to subscribers or other applications.


2 Answers

There is an interesting technique that is used by among others Instapaper and News.me(the pioneers of this technique) where you use region monitoring to initiate background downloads or uploads. Marco (Instapaper) blogged and talked (in episode 80 of the Build and Analyze podcast) about his communication with Apple so it should be a allowed in the App Store.


In brief the technique is that you set up certain regions (geofences) like "home" or "work" and respond to the locationManager:didEnterRegion: (and similar) callback(s). Your app will wake up from the background once you enter the pre-specified region and you can check to see if there is any data to upload.

This technique won't guarantee that the data is uploaded when the network reconnects but it will allow your app to automatically upload the information when the iPod Touch users gets home to their WiFi network.

That should most likely be at least once a day which may or may not be frequent enough for you. You could add a timestamp to when the initial upload was attempted and send that along the upload once it succeeds to get the correct order of events (data entries) on your server.

like image 183
David Rönnqvist Avatar answered Sep 28 '22 17:09

David Rönnqvist


There is no way to ensure this. If your application is "not running" (by the definition described in your question), it will not be capable of responding to a change in the device's network status. It should be setup to resume upload operations the next time the application runs again.

EDIT: Some of the cases you've described may indeed provide different opportunities for your application. Specifically, if the user "exits" the app by pressing the home button or launches another app in the foreground, your application may continue to run the in the background and could potentially respond to a change in network reachability.

The nature of what may be done in the background and for how-long is well documented, and supported by any version of iOS that supports multi-tasking. I recommend you review the documentation pertaining to App States and Background Services.

like image 27
isaac Avatar answered Sep 28 '22 16:09

isaac