在 iOS 7 中检测后台应用刷新的用户设置 [英] Detecting user settings for Background App Refresh in iOS 7

查看:25
本文介绍了在 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?

解决方案

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

这篇关于在 iOS 7 中检测后台应用刷新的用户设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆