gpt4 book ai didi

objective-c - 在 iOS 7 中检测后台应用刷新的用户设置

转载 作者:IT老高 更新时间:2023-10-28 11:38:25 27 4
gpt4 key购买 nike

从 iOS 7 开始,Apple 的多任务 API 允许应用程序以三种新的后台模式运行:后台获取、远程通知内容和后台传输服务。 Apple 还让 iOS 用户能够控制是否允许所有应用程序在后台运行,或者单个应用程序是否可以在后台运行(设置 > 常规 > 后台应用程序刷新)。我的应用是否有办法以编程方式检测用户是否禁用了我的应用在后台刷新的功能?

最佳答案

这就是你要找的。

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

关于objective-c - 在 iOS 7 中检测后台应用刷新的用户设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18520787/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com