123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- //
- // APPdelegateModularForVendor.m
- // jiaPei
- //
- // Created by 张嵘 on 2019/3/26.
- // Copyright © 2019 JCZ. All rights reserved.
- //
- #import "APPdelegateModularForVendor.h"
- #import "RQAppEventAnnotation.h"
- /// bugly腾讯bug统计
- #import <Bugly/Bugly.h>
- /// 百度地图
- #import <BaiduMapAPI_Base/BMKMapManager.h>
- #import <BMKLocationkit/BMKLocationComponent.h>
- /// SMS短信验证
- //#import <SMS_SDK/SMSSDK.h>
- /// 分享
- //#import <ShareSDK/ShareSDK.h>
- //#import <ShareSDKConnector/ShareSDKConnector.h>
- /// 腾讯开放平台(对应QQ和QQ空间)SDK头文件
- //#import <TencentOpenAPI/TencentOAuth.h>
- //#import <TencentOpenAPI/QQApiInterface.h>
- /// 微信SDK头文件
- #import "WXApi.h"
- #import "DOUAudioStreamer+Options.h"
- /// 百度人脸识别
- #import <IDLFaceSDK/IDLFaceSDK.h>
- #import "FaceParameterConfig.h"
- #import "BDFaceAdjustParamsTool.h"
- #import "BDFaceLivingConfigModel.h"
- /// bugly
- #define BUGLY_APP_ID @"a2bb8e84bc"
- RQAppEventMod(APPdelegateModularForVendor)
- @interface APPdelegateModularForVendor () <BMKGeneralDelegate, BMKLocationAuthDelegate,WXApiDelegate>
- @end
- @implementation APPdelegateModularForVendor
- - (NSInteger)moduleLevel {
- return 2;
- }
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- [self initMudule];
- // [self destroyModule];
- return YES;
- }
- - (void)initMudule {
- /// 初始化Bugly
- [self initBugly];
- /// 初始化百度地图
- [self initBaiduMap];
- /// 初始化ShareSDK
- [self initShareSDK];
- /// 初始化百度人脸识别SDK
- [self initDBFaceSDK];
- /// 初始化YYCache
- [self initYYCache];
- /// 初始化SDImageWebPCoder
- [self initSDImageWebPCoder];
- /// 配置流音乐播放
- // [self initDOUAudioStreamer];
- /// 启动页
- // if (!RQ_COMMON_MANAGER.JSJP_APP_AD_OPEN && !myDelegate.adIsShow) {
- // [self initBeginAD];
- // myDelegate.adIsShow = YES;
- // }
- }
- #pragma mark - 初始化Bugly
- - (void)initBugly {
- //异常统计
- #ifdef DEBUG
- //do sth1.
- [Bugly startWithAppId:BUGLY_APP_ID];
- #else
- [Bugly startWithAppId:BUGLY_APP_ID];
- #endif
- }
- #pragma mark - 初始化百度地图
- - (void)initBaiduMap {
- [LOCATION_MANAGER updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
-
- }];
- // dispatch_async_on_main_queue(^{
- // //初始化地图
- // BMKMapManager *mapManager = [[BMKMapManager alloc]init];
- // // 如果要关注网络及授权验证事件,请设定 generalDelegate参数
- // BOOL ret = [mapManager start:BaiDuMapAK generalDelegate:self];
- // if (!ret) {
- // //NSLog(@"%d",ret);
- // NSLog(@"manager start failed!");
- // }
- // //百度地图定位
- // [[BMKLocationAuth sharedInstance] checkPermisionWithKey:BaiDuMapAK authDelegate:self];
- // // ‼️重要:设置用户是否同意SDK隐私协议,请务必在BMKLocationManager和BMKGeoFenceManager实例化之前调用,否则实例化失败
- // [[BMKLocationAuth sharedInstance] setAgreePrivacy:YES];
- // });
- }
- #pragma mark - 百度地图的代理
- - (void)onGetNetworkState:(int)iError {
- if (0 == iError) {
- NSLog(@"联网成功");
- }
- else {
- NSLog(@"联网失败");
- }
-
- }
- - (void)onGetPermissionState:(int)iError {
- if (0 == iError) {
- NSLog(@"授权成功");
- }
- else {
- NSLog(@"授权失败");
- }
- }
- #pragma mark - 初始化ShareSDK
- - (void)initShareSDK {
- //注册分享
- // [ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
- // //QQ
- //// [platformsRegister setupQQWithAppId:@"1105901490" appkey:@"DAqzov5RGSBXFWAT" enableUniversalLink:false universalLink:nil];
- //
- // //更新到4.3.3或者以上版本,微信初始化需要使用以下初始化
- // [platformsRegister setupWeChatWithAppId:RQ_WECHAT_MANAGER.appID appSecret:RQ_WECHAT_MANAGER.appSecret universalLink:RQ_WECHAT_MANAGER.universalLink];
- //
- // }];
- }
- #pragma mark - initDBFaceSDK
- - (void)initDBFaceSDK {
- [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"SoundMode"];
- [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"LiveMode"];
- [[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:@"ByOrder"];
- [[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:@"checkAgreeBtn"];
-
- NSString* licensePath = [NSString stringWithFormat:@"%@.%@", FACE_LICENSE_NAME, FACE_LICENSE_SUFFIX ];
- [[FaceSDKManager sharedInstance] setLicenseID:FACE_LICENSE_ID andLocalLicenceFile:licensePath andRemoteAuthorize:false];
- NSLog(@"canWork = %d",[[FaceSDKManager sharedInstance] canWork]);
- NSLog(@"version = %@",[[FaceSDKManager sharedInstance] getVersion]);
- [self initSDK];
- [self initLivenesswithList];
- }
- - (void)initSDK {
-
- if (![[FaceSDKManager sharedInstance] canWork]){
- NSLog(@"授权失败,请检测ID 和 授权文件是否可用");
- return;
- }
-
- // 初始化SDK配置参数,可使用默认配置
- // 设置最小检测人脸阈值
- [[FaceSDKManager sharedInstance] setMinFaceSize:200];
- // 设置截取人脸图片高
- [[FaceSDKManager sharedInstance] setCropFaceSizeWidth:480];
- // 设置截取人脸图片宽
- [[FaceSDKManager sharedInstance] setCropFaceSizeHeight:640];
- // 设置人脸遮挡阀值
- [[FaceSDKManager sharedInstance] setOccluThreshold:0.5];
- // 设置亮度阀值
- [[FaceSDKManager sharedInstance] setMinIllumThreshold:40];
- [[FaceSDKManager sharedInstance] setMaxIllumThreshold:240];
- // 设置图像模糊阀值
- [[FaceSDKManager sharedInstance] setBlurThreshold:0.3];
- // 设置头部姿态角度
- [[FaceSDKManager sharedInstance] setEulurAngleThrPitch:10 yaw:10 roll:10];
- // 设置人脸检测精度阀值
- [[FaceSDKManager sharedInstance] setNotFaceThreshold:0.6];
- // 设置抠图的缩放倍数
- [[FaceSDKManager sharedInstance] setCropEnlargeRatio:2.5];
- // 设置照片采集张数
- [[FaceSDKManager sharedInstance] setMaxCropImageNum:3];
- // 设置超时时间
- [[FaceSDKManager sharedInstance] setConditionTimeout:15];
- // 设置开启口罩检测,非动作活体检测可以采集戴口罩图片
- [[FaceSDKManager sharedInstance] setIsCheckMouthMask:true];
- // 设置开启口罩检测情况下,非动作活体检测口罩过滤阈值,默认0.8 不需要修改
- [[FaceSDKManager sharedInstance] setMouthMaskThreshold:0.8f];
- // 设置原始图缩放比例
- [[FaceSDKManager sharedInstance] setImageWithScale:0.8f];
- // 设置图片加密类型,type=0 基于base64 加密;type=1 基于百度安全算法加密
- [[FaceSDKManager sharedInstance] setImageEncrypteType:0];
- // 初始化SDK功能函数
- [[FaceSDKManager sharedInstance] initCollect];
- // 设置人脸过远框比例
- [[FaceSDKManager sharedInstance] setMinRect:0.4];
-
- /// 设置用户设置的配置参数
- [BDFaceAdjustParamsTool setDefaultConfig];
- }
- - (void)initLivenesswithList {
- // 默认活体检测打开,顺序执行
- /*
- 添加当前默认的动作,是否需要按照顺序,动作活体的数量(设置页面会根据这个numOfLiveness来判断选择了几个动作)
- */
- [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveEye)];
- [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveMouth)];
- [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveYawRight)];
- [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveYawLeft)];
- [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLivePitchUp)];
- [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLivePitchDown)];
- // [BDFaceLivingConfigModel.sharedInstance.liveActionArray addObject:@(FaceLivenessActionTypeLiveYaw)];
- BDFaceLivingConfigModel.sharedInstance.isByOrder = NO;
- BDFaceLivingConfigModel.sharedInstance.numOfLiveness = 3;
- }
- - (void) destorySDK {
- // 销毁SDK功能函数
- [[FaceSDKManager sharedInstance] uninitCollect];
- }
- #pragma mark - 初始化YYCache
- - (void)initYYCache {
- YYCache *cache = [[YYCache alloc] initWithName:@"getTeachingVideoByTypeId"];
- [cache removeAllObjects];
- }
- #pragma mark - 初始化SDImageWebPCoder
- - (void)initSDImageWebPCoder {
- SDImageWebPCoder *webPCoder = [SDImageWebPCoder sharedCoder];
- [[SDImageCodersManager sharedManager] addCoder:webPCoder];
- }
- #pragma mark - 初始化配置流音乐播放
- - (void)initDOUAudioStreamer {
- [DOUAudioStreamer setOptions:[DOUAudioStreamer options] | DOUAudioStreamerRequireSHA256];
- }
- #pragma mark - 启动页广告
- - (void)initBeginAD {
- //初始化开屏广告
- [self setupXHLaunchAd];
- }
- - (void)setupXHLaunchAd{
- [self example];
- }
- /// 图片开屏广告-本地数据-示例
- /// 图片开屏广告 - 本地数据
- - (void)example {
- //设置你工程的启动页使用的是:LaunchImage 还是 LaunchScreen.storyboard(不设置默认:LaunchImage)
- [XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
- [XHLaunchAd setWaitDataDuration:0];
-
- //配置广告数据
- XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration new];
- //广告停留时间
- imageAdconfiguration.duration = 5;
- //广告frame
- imageAdconfiguration.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
- //广告图片URLString/或本地图片名(.jpg/.gif请带上后缀)
- NSString *path = @"";
- if (!RQ_COMMON_MANAGER.adPaths || RQ_COMMON_MANAGER.adPaths.count <1) {
- }else{
- path = RQ_COMMON_MANAGER.adPaths[arc4random()%RQ_COMMON_MANAGER.adPaths.count];
- }
- imageAdconfiguration.imageNameOrURLString = [path isEqualToString:@""]? @"firstAD.jpg" : path;
- imageAdconfiguration.imageOption = XHLaunchAdImageCacheInBackground;
- //图片填充模式
- imageAdconfiguration.contentMode = UIViewContentModeScaleToFill;
- //广告显示完成动画
- imageAdconfiguration.showFinishAnimate = ShowFinishAnimateFadein;
- //广告显示完成动画时间
- imageAdconfiguration.showFinishAnimateTime = 0.8;
- //跳过按钮类型
- imageAdconfiguration.skipButtonType = SkipTypeRoundProgressTime;
- //后台返回时,是否显示广告
- imageAdconfiguration.showEnterForeground = NO;
- //显示开屏广告
- [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:nil];
- }
- @end
|