Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting user settings for Background App Refresh in iOS 7

Starting with iOS 7, Apple's Multitasking APIs allow apps to run in three new Background Modes: Background fetch, Remote notification content, and Background transfer service. Apple also gives iOS users the ability to control whether all apps are allowed to run in the background or whether individual apps can run in the background (Settings > General > Background App Refresh). Is there is a way for my app to programmatically detect whether the user has disabled my app's ability to refresh in the background?

like image 985
Sydney Avatar asked Aug 29 '13 20:08

Sydney


People also ask

What is background app refresh on iPhone 7?

The "Background App Refresh" feature lets apps update even when they're closed, but it takes up battery life. To turn off the "Background App Refresh" feature on your iPhone or iPad, head to the "General" menu in the Settings app. You can turn off background refreshing for every app, or just specific apps.

Why can't I turn on my background app refresh?

If Background refresh is greyed out in the ON position, go To Settings App - > General - > Background App Refresh - > Turn on the option for the system, and then you can turn on / off by app.

Where is background app refresh on iPhone settings?

Use Background App Refresh With Background App Refresh, suspended apps can check for updates and new content. If you want suspended apps to check for new content, go to Settings > General > Background App Refresh and turn on Background App Refresh.

Where is the background app refresh in settings?

To prevent an app from using mobile data in the background, head to Settings > Apps (Apps & notifications on older versions) > See all X apps. Tap the app in the list that you want to disable background app refresh for. From this menu, you have two different options for disabling background activity in Android.


2 Answers

this is what you are looking for.

if ([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusAvailable) {      NSLog(@"Background updates are available for the app."); }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied) {     NSLog(@"The user explicitly disabled background behavior for this app or for the whole system."); }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusRestricted) {     NSLog(@"Background updates are unavailable and the user cannot enable them again. For example, this status can occur when parental controls are in effect for the current user."); } 
like image 133
dubemike Avatar answered Oct 11 '22 13:10

dubemike


Updated for Swift 3 and iOS10:

switch UIApplication.shared.backgroundRefreshStatus { case .available:     print("Refresh available") case .denied:     print("Refresh denied") case .restricted:     print("Refresh restricted") } 
like image 29
Andrew K Avatar answered Oct 11 '22 14:10

Andrew K