4

I like to determine if the user turned off Background Fetching in the Preferences app. If he turned it off my app won't work.

samwize
  • 25,675
  • 15
  • 141
  • 186
David Gölzhäuser
  • 3,525
  • 8
  • 50
  • 98

1 Answers1

6

Here is the code to do it:

if ([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusAvailable) {

    NSLog(@"Background fetch is available for the app.");
}else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied)
{
    NSLog(@"Background fetch for this app or for the whole system is disabled.");
}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.");
}
Nikos M.
  • 13,685
  • 4
  • 47
  • 61