简体   繁体   English

当用户关闭“ Background App Refresh”时,在后台模式下更新位置不起作用

[英]Update location on background mode do not work when user turn off “Background App Refresh”

I want to notify for user to turn on "Background App Refresh" to update location on background mode. 我想通知用户打开“ Background App Refresh”以在后台模式下更新位置。 How can I check status of this feature on my code? 如何在代码中检查此功能的状态?

Method 1 方法1

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

Method 2 方法2

NSArray *backgroundRefreshAuthStatuses = @[@"Restricted",@"Denied",@"Available"];
int brAuth = (int)[[UIApplication sharedApplication] backgroundRefreshStatus];
NSLog(@"Background refresh authorization status: %@", [backgroundRefreshAuthStatuses objectAtIndex:brAuth]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM