Detecting user settings for Background App Refresh in iOS 7

前端 未结 3 778
南旧
南旧 2020-12-12 16:12

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 servi

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 17:09

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

提交回复
热议问题