How to properly use location in background - app got rejected 3 times

后端 未结 3 1235
轻奢々
轻奢々 2020-12-30 11:54

My app got rejected by Apple three times, all with the same rejection letter, which is:

We found that your app uses a background mode but does not inc

相关标签:
3条回答
  • 2020-12-30 12:16

    This question is old and already answered but you dont need the UIBackgroundModes key if you collect locations using the startMonitoringSignificantLocationChanges API

    0 讨论(0)
  • 2020-12-30 12:26

    startMonitoringSignificantLocationChanges don't require a background mode registration. Only continuous location changes do.

    0 讨论(0)
  • 2020-12-30 12:28

    In locationManager:didUpdateToLocation:fromLocation: or in updateMyLocationToServer: You should check if application is in background state by eg.

    [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
    

    And then if Your app is in background mode You should use eg.

    backgroundTask = [[UIApplication sharedApplication]
                        beginBackgroundTaskWithExpirationHandler:
                        ^{
                            [[UIApplication sharedApplication] endBackgroundTask:backgroundTask];
                        }];
    
    /*Write Your internet request code here*/
    
    if (bgTask != UIBackgroundTaskInvalid)
    {
        [[UIApplication sharedApplication] endBackgroundTask:backgroundTask];
        bgTask = UIBackgroundTaskInvalid;
    }
    

    This way application should perform this task completely.

    0 讨论(0)
提交回复
热议问题