鹰眼iOS SDK V3.0及以上版本支持所有的模拟器和真机CPU架构,开发者可以使用lipo命令,根据自身的需要合成自己所需的SDK。
可以直接使用鹰眼iOS SDK进行开发测试,但是上架到APP STORE时,由于苹果公司的要求,只能使用真机对应CPU架构的SDK,所以需要开发者使用lipo命令合成自身需要的CPU架构版本的SDK。lipo命令的使用方法如下:
输入命令:
lipo -info ./BaiduTraceSDK.framework/BaiduTraceSDK
终端回显:
Architectures in the fat file: ./BaiduTraceSDK.framework/BaiduTraceSDK are: i386 x86_64 armv7 armv7s arm64
输入命令:
lipo -info ./arm64/BaiduTraceSDK
终端回显:
Non-fat file: ./arm64/BaiduTraceSDK is architecture: arm64
输入命令:
lipo -info ./armv7/BaiduTraceSDK
终端回显:
Non-fat file: ./armv7/BaiduTraceSDK is architecture: armv7
输入命令:
lipo -info ./arm64/BaiduTraceSDK
终端回显:
Non-fat file: ./arm64/BaiduTraceSDK is architecture: arm64
输入命令:
lipo -info ./armv7/BaiduTraceSDK
终端回显:
Non-fat file: ./armv7/BaiduTraceSDK is architecture: armv7
输入命令:
lipo -create ./armv7/BaiduTraceSDK ./arm64/BaiduTraceSDK -output ./BaiduTraceSDK.framework/BaiduTraceSDK
输入命令:
rm -rf ./arm64rm -rf ./armv7
输入命令:
lipo -info ./BaiduTraceSDK.framework/BaiduTraceSDK
终端回显:
Architectures in the fat file: ./BaiduTraceSDK.framework/BaiduTraceSDK are: armv7 arm64
选择需要的Target,将 BaiduTracekSDK.framework 拖入其General选项卡中的Embedded Binaries栏即可。拖入之后Linked Framework and Libraries栏也会显示 BaiduTraceSDK.framework 项,同时检查 Build Phases 选项卡中的 Embed Frameworks 栏和 Link Binary With Libraries 栏也都显示成功导入 BaiduTraceSDK.framework 项。
APP在声明定位权限时(用作APPStore上架审核),自鹰眼iOS SDK V3.1.1版本开始支持开发者声明“仅需要前台定位”或“同时需要前台和后台定位”,结合最终用户定位权限授予情况,两种声明均可实现鹰眼轨迹的采集,两者不同之处在于:
1. 声明仅需前台定位:若最终用户授权APP定位权限(允许一次/使用APP期间/始终),此时APP在前台时鹰眼可成功采集轨迹,但APP退到后台时APP被杀死可能性较高,易造成轨迹中断。仅声明前台定位权限需在info.plist文件源码中增加以下声明:
<key>NSLocationWhenInUseUsageDescription</key><string>文字阐述需要前台定位的原因</string>
2. 声明同时需要前台和后台定位:若最终用户授权APP定位权限为“始终”时,不论APP在前台还是后台,APP被杀死概率较低,这种方式可尽量保证轨迹采集不中断。若最终用户授权APP定位权限为“允许一次/使用APP期间”时,APP在前台时鹰眼可成功采集轨迹,退到后台时APP被杀死可能性较高,易造成轨迹中断。同时声明前台和后台定位权限需在info.plist文件源码中增加以下声明:
<key>NSLocationWhenInUseUsageDescription</key><string>文字阐述需要前台定位的原因</string><key>NSLocationAlwaysAndWhenInUseUsageDescription</key><string>文字阐述需要后台定位的原因</string><key>NSLocationAlwaysUsageDescription</key><string>文字阐述需要后台定位的原因</string><key>UIBackgroundModes</key><array><string>location</string></array>
开发者需结合plist文件中的配置申请相应的定位权限:
- (void)requestLocAuthByPlist {NSBundle *bundle = [NSBundle mainBundle];NSObject *accessTypeAlways = [bundle objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"];NSObject *accessTypeWhen = [bundle objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"];NSObject *accessTypeBoth = [bundle objectForInfoDictionaryKey:@"NSLocationAlwaysAndWhenInUseUsageDescription"];if (accessTypeAlways && accessTypeWhen && accessTypeBoth) {// 申请前后台定位权限[self.locationManager requestAlwaysAuthorization];} else if (accessTypeWhen){// 申请前台定位权限[self.locationManager requestWhenInUseAuthorization];}}
1.用户关闭准确位置权限情况下,使用鹰眼服务前开发者可以根据需求选择申请临时精确位置权限:
#pragma mark - CLLocationManagerDelegate/// 适配iOS14#ifndef __IPHONE_14_0#define __IPHONE_14_0 140000#endif#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0//监听定位权限状态改变,及时采取合理措施- (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager {if (@available(iOS 14.0, *)) {NSObject *temporaryUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationTemporaryUsageDescriptionDictionary"];if (temporaryUsageDescription && self.locationManager.accuracyAuthorization == CLAccuracyAuthorizationReducedAccuracy) {// iOS14之后根据产品需求申请临时访问精确位置权限// 1.在info.plist配置// <key>NSLocationTemporaryUsageDescriptionDictionary</key>// <dict>// <key>WantsToTrace</key>// <string>鹰眼需要高精度定位权限</string>// </dict>// 2.申请权限[self.locationManager requestTemporaryFullAccuracyAuthorizationWithPurposeKey:@"WantsToTrace" completion:^(NSError * _Nullable error) {NSLog(@"%@", error);}];}} else {// Fallback on earlier versions}}#endif
2. 启用后台位置指示器,进入后台时保留被授予的临时访问权限(精确位置):
//需要在开始采集前设置[[BTKAction sharedInstance] showsBackgroundLocationIndicator:YES];[[BTKAction sharedInstance] startGather:self];
为避免这种情况,开发者需要在上架的描述信息中说明清楚,是APP的哪些特性和功能必须要使用后台定位权限。
上一篇
下一篇
本篇文章对您是否有帮助?