4
我喜歡確定用戶是否在首選項應用中關閉了背景抓取。如果他關掉了我的應用程序將無法正常工作。如何檢查iOS上是否啓用了BackgroundFetching?
我喜歡確定用戶是否在首選項應用中關閉了背景抓取。如果他關掉了我的應用程序將無法正常工作。如何檢查iOS上是否啓用了BackgroundFetching?
下面是代碼做到這一點:
if ([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusAvailable) {
NSLog(@"Background fetch is available for the app.");
}else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied)
{
NSLog(@"Background fetch for this app or for the whole system is disabled.");
}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.");
}