APPdelegateModularForVendor.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. //
  2. // APPdelegateModularForVendor.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2019/3/26.
  6. // Copyright © 2019 JCZ. All rights reserved.
  7. //
  8. #import "APPdelegateModularForVendor.h"
  9. #import "RQAppEventAnnotation.h"
  10. /// bugly腾讯bug统计
  11. #import <Bugly/Bugly.h>
  12. /// 百度地图
  13. #import <BaiduMapAPI_Base/BMKMapManager.h>
  14. #import <BMKLocationkit/BMKLocationComponent.h>
  15. /// SMS短信验证
  16. //#import <SMS_SDK/SMSSDK.h>
  17. /// 分享
  18. //#import <ShareSDK/ShareSDK.h>
  19. //#import <ShareSDKConnector/ShareSDKConnector.h>
  20. /// 腾讯开放平台(对应QQ和QQ空间)SDK头文件
  21. //#import <TencentOpenAPI/TencentOAuth.h>
  22. //#import <TencentOpenAPI/QQApiInterface.h>
  23. /// 微信SDK头文件
  24. #import "WXApi.h"
  25. #import "DOUAudioStreamer+Options.h"
  26. /// 百度人脸识别
  27. #import <IDLFaceSDK/IDLFaceSDK.h>
  28. #import "FaceParameterConfig.h"
  29. #import "BDFaceAdjustParamsTool.h"
  30. #import "BDFaceLivingConfigModel.h"
  31. /// bugly
  32. #define BUGLY_APP_ID @"a2bb8e84bc"
  33. RQAppEventMod(APPdelegateModularForVendor)
  34. @interface APPdelegateModularForVendor () <BMKGeneralDelegate, BMKLocationAuthDelegate,WXApiDelegate>
  35. @end
  36. @implementation APPdelegateModularForVendor
  37. - (NSInteger)moduleLevel {
  38. return 2;
  39. }
  40. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  41. [self initMudule];
  42. // [self destroyModule];
  43. return YES;
  44. }
  45. - (void)initMudule {
  46. /// 初始化Bugly
  47. [self initBugly];
  48. /// 初始化百度地图
  49. [self initBaiduMap];
  50. /// 初始化ShareSDK
  51. [self initShareSDK];
  52. /// 初始化百度人脸识别SDK
  53. [self initDBFaceSDK];
  54. /// 初始化YYCache
  55. [self initYYCache];
  56. /// 初始化SDImageWebPCoder
  57. [self initSDImageWebPCoder];
  58. /// 配置流音乐播放
  59. // [self initDOUAudioStreamer];
  60. /// 启动页
  61. // if (!RQ_COMMON_MANAGER.JSJP_APP_AD_OPEN && !myDelegate.adIsShow) {
  62. // [self initBeginAD];
  63. // myDelegate.adIsShow = YES;
  64. // }
  65. }
  66. #pragma mark - 初始化Bugly
  67. - (void)initBugly {
  68. //异常统计
  69. #ifdef DEBUG
  70. //do sth1.
  71. [Bugly startWithAppId:BUGLY_APP_ID];
  72. #else
  73. [Bugly startWithAppId:BUGLY_APP_ID];
  74. #endif
  75. }
  76. #pragma mark - 初始化百度地图
  77. - (void)initBaiduMap {
  78. [LOCATION_MANAGER updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
  79. }];
  80. // dispatch_async_on_main_queue(^{
  81. // //初始化地图
  82. // BMKMapManager *mapManager = [[BMKMapManager alloc]init];
  83. // // 如果要关注网络及授权验证事件,请设定 generalDelegate参数
  84. // BOOL ret = [mapManager start:BaiDuMapAK generalDelegate:self];
  85. // if (!ret) {
  86. // //NSLog(@"%d",ret);
  87. // NSLog(@"manager start failed!");
  88. // }
  89. // //百度地图定位
  90. // [[BMKLocationAuth sharedInstance] checkPermisionWithKey:BaiDuMapAK authDelegate:self];
  91. // // ‼️重要:设置用户是否同意SDK隐私协议,请务必在BMKLocationManager和BMKGeoFenceManager实例化之前调用,否则实例化失败
  92. // [[BMKLocationAuth sharedInstance] setAgreePrivacy:YES];
  93. // });
  94. }
  95. #pragma mark - 百度地图的代理
  96. - (void)onGetNetworkState:(int)iError {
  97. if (0 == iError) {
  98. NSLog(@"联网成功");
  99. }
  100. else {
  101. NSLog(@"联网失败");
  102. }
  103. }
  104. - (void)onGetPermissionState:(int)iError {
  105. if (0 == iError) {
  106. NSLog(@"授权成功");
  107. }
  108. else {
  109. NSLog(@"授权失败");
  110. }
  111. }
  112. #pragma mark - 初始化ShareSDK
  113. - (void)initShareSDK {
  114. //注册分享
  115. // [ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
  116. // //QQ
  117. //// [platformsRegister setupQQWithAppId:@"1105901490" appkey:@"DAqzov5RGSBXFWAT" enableUniversalLink:false universalLink:nil];
  118. //
  119. // //更新到4.3.3或者以上版本,微信初始化需要使用以下初始化
  120. // [platformsRegister setupWeChatWithAppId:RQ_WECHAT_MANAGER.appID appSecret:RQ_WECHAT_MANAGER.appSecret universalLink:RQ_WECHAT_MANAGER.universalLink];
  121. //
  122. // }];
  123. }
  124. #pragma mark - initDBFaceSDK
  125. - (void)initDBFaceSDK {
  126. [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"SoundMode"];
  127. [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"LiveMode"];
  128. [[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:@"ByOrder"];
  129. [[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:@"checkAgreeBtn"];
  130. NSString* licensePath = [NSString stringWithFormat:@"%@.%@", FACE_LICENSE_NAME, FACE_LICENSE_SUFFIX ];
  131. [[FaceSDKManager sharedInstance] setLicenseID:FACE_LICENSE_ID andLocalLicenceFile:licensePath andRemoteAuthorize:false];
  132. NSLog(@"canWork = %d",[[FaceSDKManager sharedInstance] canWork]);
  133. NSLog(@"version = %@",[[FaceSDKManager sharedInstance] getVersion]);
  134. [self initSDK];
  135. [self initLivenesswithList];
  136. }
  137. - (void)initSDK {
  138. if (![[FaceSDKManager sharedInstance] canWork]){
  139. NSLog(@"授权失败,请检测ID 和 授权文件是否可用");
  140. return;
  141. }
  142. // 初始化SDK配置参数,可使用默认配置
  143. // 设置最小检测人脸阈值
  144. [[FaceSDKManager sharedInstance] setMinFaceSize:200];
  145. // 设置截取人脸图片高
  146. [[FaceSDKManager sharedInstance] setCropFaceSizeWidth:480];
  147. // 设置截取人脸图片宽
  148. [[FaceSDKManager sharedInstance] setCropFaceSizeHeight:640];
  149. // 设置人脸遮挡阀值
  150. [[FaceSDKManager sharedInstance] setOccluThreshold:0.5];
  151. // 设置亮度阀值
  152. [[FaceSDKManager sharedInstance] setMinIllumThreshold:40];
  153. [[FaceSDKManager sharedInstance] setMaxIllumThreshold:240];
  154. // 设置图像模糊阀值
  155. [[FaceSDKManager sharedInstance] setBlurThreshold:0.3];
  156. // 设置头部姿态角度
  157. [[FaceSDKManager sharedInstance] setEulurAngleThrPitch:10 yaw:10 roll:10];
  158. // 设置人脸检测精度阀值
  159. [[FaceSDKManager sharedInstance] setNotFaceThreshold:0.6];
  160. // 设置抠图的缩放倍数
  161. [[FaceSDKManager sharedInstance] setCropEnlargeRatio:2.5];
  162. // 设置照片采集张数
  163. [[FaceSDKManager sharedInstance] setMaxCropImageNum:3];
  164. // 设置超时时间
  165. [[FaceSDKManager sharedInstance] setConditionTimeout:15];
  166. // 设置开启口罩检测,非动作活体检测可以采集戴口罩图片
  167. [[FaceSDKManager sharedInstance] setIsCheckMouthMask:true];
  168. // 设置开启口罩检测情况下,非动作活体检测口罩过滤阈值,默认0.8 不需要修改
  169. [[FaceSDKManager sharedInstance] setMouthMaskThreshold:0.8f];
  170. // 设置原始图缩放比例
  171. [[FaceSDKManager sharedInstance] setImageWithScale:0.8f];
  172. // 设置图片加密类型,type=0 基于base64 加密;type=1 基于百度安全算法加密
  173. [[FaceSDKManager sharedInstance] setImageEncrypteType:0];
  174. // 初始化SDK功能函数
  175. [[FaceSDKManager sharedInstance] initCollect];
  176. // 设置人脸过远框比例
  177. [[FaceSDKManager sharedInstance] setMinRect:0.4];
  178. /// 设置用户设置的配置参数
  179. [BDFaceAdjustParamsTool setDefaultConfig];
  180. }
  181. - (void)initLivenesswithList {
  182. // 默认活体检测打开,顺序执行
  183. /*
  184. 添加当前默认的动作,是否需要按照顺序,动作活体的数量(设置页面会根据这个numOfLiveness来判断选择了几个动作)
  185. */
  186. [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveEye)];
  187. [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveMouth)];
  188. [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveYawRight)];
  189. [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveYawLeft)];
  190. [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLivePitchUp)];
  191. [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLivePitchDown)];
  192. // [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveYaw)];
  193. BDFaceLivingConfigModel.sharedInstance.isByOrder = NO;
  194. BDFaceLivingConfigModel.sharedInstance.numOfLiveness = 3;
  195. }
  196. - (void) destorySDK {
  197. // 销毁SDK功能函数
  198. [[FaceSDKManager sharedInstance] uninitCollect];
  199. }
  200. #pragma mark - 初始化YYCache
  201. - (void)initYYCache {
  202. YYCache *cache = [[YYCache alloc] initWithName:@"getTeachingVideoByTypeId"];
  203. [cache removeAllObjects];
  204. }
  205. #pragma mark - 初始化SDImageWebPCoder
  206. - (void)initSDImageWebPCoder {
  207. SDImageWebPCoder *webPCoder = [SDImageWebPCoder sharedCoder];
  208. [[SDImageCodersManager sharedManager] addCoder:webPCoder];
  209. }
  210. #pragma mark - 初始化配置流音乐播放
  211. - (void)initDOUAudioStreamer {
  212. [DOUAudioStreamer setOptions:[DOUAudioStreamer options] | DOUAudioStreamerRequireSHA256];
  213. }
  214. #pragma mark - 启动页广告
  215. - (void)initBeginAD {
  216. //初始化开屏广告
  217. [self setupXHLaunchAd];
  218. }
  219. - (void)setupXHLaunchAd{
  220. [self example];
  221. }
  222. /// 图片开屏广告-本地数据-示例
  223. /// 图片开屏广告 - 本地数据
  224. - (void)example {
  225. //设置你工程的启动页使用的是:LaunchImage 还是 LaunchScreen.storyboard(不设置默认:LaunchImage)
  226. [XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
  227. [XHLaunchAd setWaitDataDuration:0];
  228. //配置广告数据
  229. XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration new];
  230. //广告停留时间
  231. imageAdconfiguration.duration = 5;
  232. //广告frame
  233. imageAdconfiguration.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
  234. //广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
  235. NSString *path = @"";
  236. if (!RQ_COMMON_MANAGER.adPaths || RQ_COMMON_MANAGER.adPaths.count <1) {
  237. }else{
  238. path = RQ_COMMON_MANAGER.adPaths[arc4random()%RQ_COMMON_MANAGER.adPaths.count];
  239. }
  240. imageAdconfiguration.imageNameOrURLString = [path isEqualToString:@""]? @"firstAD.jpg" : path;
  241. imageAdconfiguration.imageOption = XHLaunchAdImageCacheInBackground;
  242. //图片填充模式
  243. imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
  244. //广告显示完成动画
  245. imageAdconfiguration.showFinishAnimate = ShowFinishAnimateFadein;
  246. //广告显示完成动画时间
  247. imageAdconfiguration.showFinishAnimateTime = 0.8;
  248. //跳过按钮类型
  249. imageAdconfiguration.skipButtonType = SkipTypeRoundProgressTime;
  250. //后台返回时,是否显示广告
  251. imageAdconfiguration.showEnterForeground = NO;
  252. //显示开屏广告
  253. [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:nil];
  254. }
  255. @end