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

查看:181
本文介绍了检测用户设置后台应用刷新iOS中7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与iOS 7起,苹果的多任务处理的API允许应用在三个新背景模式运行:背景获取,远程通知的内容,背景和接送服务。苹果也给iOS用户来控制所有的应用程序是否允许在后台还是个人应用程序可以在后台(设置>通用​​>后台应用刷新)运行运行的能力。有没有对我的应用程序以编程方式检测用户是否已禁用我的应用程序在后台刷新能力的一种方式?

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?

推荐答案

这是你要找的是什么

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天全站免登陆