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?
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.
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.
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.
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.
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."); }
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") }
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