2.3.0 二进制文件被拒绝

苹果被拒信息如下:

Guideline 2.5.4 - Performance - Software Requirements

Your app declares support for location in the UIBackgroundModes key in your Info.plist file but does not have any features that require persistent location. Apps that declare support for location in the UIBackgroundModes key in your Info.plist file must have features that require persistent location.

Next Steps

To resolve this issue, please revise your app to include features that require the persistent use of real-time location updates while the app is in the background.

If your app does not require persistent real-time location updates, please remove the "location" setting from the UIBackgroundModes key. You may wish to use the significant-change location service or the region monitoring location service if persistent real-time location updates are not required for your app features.

具体原因是项目导入百度地图要求配置了UIBackgroundModes

删除对应项后,运行程序,会导致项目崩溃

*** Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:]XXX

解决步骤:

删除UIBackgroundModes设置,在项目中创建CLLationManager的类目,使用runtime方式来监听

网上查到的资料显示要导入到.pch文件中作为全局,但实际中未导入,依然可行

.m文件内容如下

+ (void)load {


    if ([UIDevice currentDevice].systemVersion.floatValue >= 9.0) {

        method_exchangeImplementations(class_getInstanceMethod(self.class, NSSelectorFromString(@"setAllowsBackgroundLocationUpdates:")), class_getInstanceMethod(self.class, @selector(swizzledSetAllowsBackgroundLocationUpdates:)));


    }

}

- (void)swizzledSetAllowsBackgroundLocationUpdates:(BOOL)allow {


    if(allow) {

        NSArray* backgroundModes = [[NSBundlemainBundle].infoDictionaryobjectForKey:@"UIBackgroundModes"];

        if( backgroundModes && [backgroundModescontainsObject:@"location"]) {

            [self swizzledSetAllowsBackgroundLocationUpdates:allow];

        }else{

            NSLog(@"APP想设置后台定位,但APP的info.plist里并没有申请后台定位");

        }

    }else{

        [self swizzledSetAllowsBackgroundLocationUpdates:allow];


    }


}


.h不需要内容

你可能感兴趣的:(2.3.0 二进制文件被拒绝)