How can I enable my app to use iOS 7 background update capability? I notice some apps already do it, but it doesn't seem to be automatic for all.
Background app refresh is a feature of iOS and Android that allows apps to update their content from the internet, even while you're not using them. In contrast, we say that apps use data in the foreground when you open and use them yourself.
Some apps keep running in the background when you return to the home screen. You can set your mobile phone to refresh apps in the background so that you'll still get notifications even if the app isn't actively in use.
According to What's New in iOS 7, what you're looking for is described as:
Apps that regularly update their content by contacting a server can register with the system and be launched periodically to retrieve that content in the background. To register, include the
UIBackgroundModes
key with thefetch
value in your app’sInfo.plist
file. Then, when your app is launched, call thesetMinimumBackgroundFetchInterval:
method to determine how often it receives update messages. Finally, you must also implement theapplication:performFetchWithCompletionHandler:
method in your app delegate.
Inside, application:performFetchWithCompletionHandler:
, you have a total of 30 seconds to finish executing what you need to do before you have to call the completionHandler. It's definitely advised to execute your poll as quickly as possible and call completionHandler as soon as you're done with your execution. If you don't call it within the allotted 30 seconds, your app will be suspended from background fetching. Or, if you start taking a long time for each fetch, your app will get fewer opportunities to perform background fetches in the future.
Alternatively, if you were looking to execute additional code when a push notification is received:
Apps that use push notifications to notify the user that new content is available can fetch the content in the background. To support this mode, include the
UIBackgroundModes
key with theremote-notification
value in your app’sInfo.plist
file. You must also implement theapplication:didReceiveRemoteNotification:fetchCompletionHandler:
method in your app delegate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With