
//  AppDelegate.m
//  Open
//
//  Created by 黄江涛 on 16/9/6.
//  Copyright © 2016年 黄江涛. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "PhotoViewController.h"
#import "XLJNewFetureController.h"
#import "TRNavigationController.h"
//#import "DemoPreDefine.h"
#import "uitableViewController.h"


#import "smallTableVController.h"
#import "AppDelegate.h"
#import "tabViewController.h"
#import "NewsNetModel.h"
#define USHARE_DEMO_APPKEY @"5861e5daf5ade41326001eab"
#import "UIImageView+WebCache.h"
//test
#import "kankanshebaoxieyi.h"


#ifdef NSFoundationVersionNumber_iOS_9_x_Max
#import <UserNotifications/UserNotifications.h>


//
#import <Bugly/Bugly.h>


//友盟
#import <UMCommon/UMCommon.h>
#import <UMShare/UMShare.h>




//#import <CL_ShanYanSDK/CL_ShanYanSDK.h>
#import "GTCountSDK.h"
#import "WXApi.h"


#import <GInsightSDK.h>
#import <AdSupport/AdSupport.h>

//极光统计
#import <JANALYTICSService.h>


//版本更新
#import "VersionUpdateTool.h"





//百度地图
#import <BMKLocationKit/BMKLocationComponent.h>


//自定义广告
#import "MyAdViewController.h"
#import "CTShowAdTypeQuest.h"



//腾讯广告
#import <GDTMobSDK/GDTSDKConfig.h>
#import <GDTMobSDK/GDTSplashAd.h>




#import "CTAPIBaseManager.h"
#import "Constants.h"

//键盘
#import <IQKeyboardManager.h>
#import "SVProgressHUD+Extension.h"


//微信
#import "WXApiManager.h"

//药兜网
#import "YDAuthenticationHelper.h"

//喜马拉雅
#import "XMSDK.h"

//极光小视频
#if TARGET_IPHONE_SIMULATOR

#else
//#import <JUnion/JUnion.h>
#endif


//快手
#import <KSAdSDK/KSAdSDK.h>
#import "KSBulletScreenManager.h"
//金丝雀
#import <CXHAdSDK-Core/CXHAdSDK.h>
//变现猫
#import "DHCWSDKConfig.h"

#import <AppTrackingTransparency/AppTrackingTransparency.h>


#import <MediaPlayer/MediaPlayer.h>



#import "StartPageViewController.h"
#import "NewsWebViewController.h"


#import "TABAnimated.h"

#import "TABAnimatedBall.h"


//小满
#import <BXMediaSDK/BXMediaCenterSDK.h>

#import <AdSupport/AdSupport.h>

#import "KKNavViewController.h"

//听听
#import "KKLisenViewController.h"
//金币中心
#import "CoinsCenterViewController.h"
//社保缴费
#import "SSPaymenyViewController.h"

//免费果园
#import "MyFruitViewController.h"

//快手视频
#import "KKSVideoViewController.h"


//存钱罐
#import "StatisticsViewController.h"
#import "SaveTabBarController.h"
#import "SaveProductListController.h"
#import "MyAssetsController.h"
#import "LittleGoldHouseWebVC.h"
#import "ProductDetailController.h"
#import "KKActivityRedPackageBaseView.h"
#import "KKCLFundViewController.h"

//新闻
#import "HeadLineViewController.h"

//我的钱包
#import "MyWalletViewController.h"

//金币排名
#import "CoinsRankViewController.h"

//收益排行榜
#import "MyRankViewController.h"


//我的奖品
#import "MyPrizeListVC.h"

//邀请好友
#import "ShareViewController.h"

//社保认证
#import "KKUserIdentifyViewController.h"

//补贴认证
#import "DistrictAuthenticationPersonalInfoController.h"

//平价药房
#import "YDTempUrlInstance.h"

#import "SecondStartPageViewController.h"

////ADmobile
//#import <ADSuyiSDK/ADSuyiSDK.h>
//#import <ADSuyiSDK/ADSuyiSDKSplashAd.h>
//凡泰
#import <FinApplet/FinApplet.h>

#import <esscsdk/esscsdk.h>
//mob一键登录和推送
#import <MOBFoundation/MobSDK+Privacy.h>
#import <MobPush/MobPush.h>
//穿山甲gromore
#import <BUAdSDK/BUAdSDK.h>
//#import <YXLaunchAds/YXLaunchAds.h>

#define kGcAppId @"Ued41NRq7j9Nh1qI81gQ54"
#define kGcAppKey  @"2tLtJhcpij7lu3ksutgpU3"
#define kGcAppSecret    @"2CgTPPlPSX6aTFBE2XSXA5"

#define CurrentWindow [self getCurrentWindowView]
#endif
@interface AppDelegate ()<BMKLocationAuthDelegate,MYAdClickDelegate,CTShowAdTypeQuestDelegate,GDTSplashAdDelegate,KSSplashAdViewDelegate,XMReqDelegate,StartPageViewControllerDelegate,SecondStartPageViewControllerDelegate,BUMSplashAdDelegate>
{
    BOOL loadedAD;
}
@property (nonatomic, assign) NSTimeInterval lastActiveTime;
@property (nonatomic, assign) BOOL didEnterBackground;

@property(nonatomic,strong)     NSMutableArray *mArray;
@property(nonatomic,strong)UIViewController *splashView;

@property(nonatomic,strong)     NSString *webTitle;
@property(nonatomic,strong)     NSString *webUrl;


@property (strong, nonatomic) ViewController *viewController;
@property (assign, nonatomic) int lastPayloadIndex;

@property (nonatomic, assign) BOOL isShow;
@property(nonatomic,strong)UIViewController *vc;



//腾讯
@property (strong, nonatomic) GDTSplashAd *txSplash;



//快手
@property (nonatomic, strong)KSSplashAdView *ksSplashAdView;

//模拟启动图
@property (nonatomic, strong)UIView *bottom;

@property (nonatomic, strong)MyAdViewController *adVC;

@property (nonatomic, strong)StartPageViewController* pageVC;

@property (nonatomic, strong)tabViewController *tabVC;


//广告
@property (nonatomic, strong)CTShowAdTypeQuest *adRequest;
@property (nonatomic, strong)BUSplashAd *splashAd;

@property (nonatomic, strong)UIImageView* lauchImageView;

@property (nonatomic, assign)BOOL showKuaishou;

@property (nonatomic, assign)CFAbsoluteTime start;

@property (nonatomic, assign)CFAbsoluteTime end;

//ADmobile


@property (nonatomic, strong) NSMutableDictionary *OpenpostNotiDic;
@property(nonatomic, assign) BOOL showAd;
@end
@implementation AppDelegate

@synthesize window =_window;
@synthesize isLogin;
@synthesize isHuoti;
@synthesize isTel;
@synthesize telStr;
@synthesize telephoneLoginStr;
@synthesize telephoneLoginPassport;
@synthesize jin;
@synthesize wei;
@synthesize changeProgress;
@synthesize mySelfSignation;

-(NSMutableArray *)mArray
{
    if (!_mArray) {
        _mArray =@[@"socialSecurity1.jpg",@"socialSecurity2.jpg",@"socialSecurity3.jpg"].mutableCopy;
    }
    return _mArray;
}
-(NSMutableArray *)numberXMLArray
{
    if (!_numberXMLArray) {
        _numberXMLArray =[NSMutableArray array];
    }
    return _numberXMLArray;
}


#pragma mark - life cycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    NSLog(@"启动程序，didFinishLaunchingWithOptions");
    
    
    if (@available(iOS 13.0, *)) {

        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;

    } else {
        
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;

    }
    
    //雷俊博注释
//    self.telephoneLoginStr=DIANHUAHUAOMA;
//    self.telephoneLoginPassport =MIMAPASSPORT;
    
    // 不再在启动时强制置为未登录，否则冷启动点击推送时已登录用户会被误判为未登录；仅在下述场景置为未登录：首次安装引导、用户主动退出登录、会话失效等
    // [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstlog"];
    // [UserDefault setInteger:0 forKey:@"appleLoginState"];
    
    //NSString * idfa = [ASIdentifierManager.sharedManager advertisingIdentifier].UUIDString;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkJumpToLoginVC:) name:KKSBJumpLoginVCNotificationName object:nil];
    
    /* 以下为小鹅通内嵌店铺SDK初始化代码段 */
    // 创建配置 clientId 从小鹅通申请的 sdk 应用 Id， appId 从小鹅通申请的店铺 Id
//    XEConfig *xeconfig = [[XEConfig alloc] initWithClientId:@"BN8ac6waRrnW" appId: @"appxdlgpgeh6116"];
//    // 关闭 SDK 日志输出
//    xeconfig.enableLog = YES;
//    // 配置你app独立的 Scheme 以便微信支付完成后跳转返回
//    xeconfig.scheme = @"com.weface.kankanlife";
//    // 初始化SDK
//    [XESDK.shared initializeSDKWithConfig:xeconfig];
    
    
    //云晴
    //[YXAdSDKManager defaultManager].channelID = @"kksh-ios";
    
    
    //[ABUAdSDKManager setLoglevel:ABUAdSDKLogLevelDebug language:ABUAdSDKLogLanguageCH];
    //[ABUAdSDKManager setAppID:@"5109638"];
    //NSLog(@"穿山甲聚合SDK版本:%@",[BUAdSDKManager SDKVersion]);
    //NSLog(@"穿山甲SDK版本:%@",[BUAdSDKManager SDKVersion]);
    NSLog(@"广点通SDK版本:%@",[GDTSDKConfig sdkVersion]);
    NSLog(@"快手SDK版本:%@",[KSAdSDKManager SDKVersion]);
    NSLog(@"喜马拉雅SDK版本:%@",[XMReqMgr version]);
    
    
    //穿山甲广告
    //[BUAdSDKManager setAppID:@"5109638"];
    //[BUAdSDKManager setLoglevel:BUAdSDKLogLevelDebug];
    //NSLog(@"穿山甲当前版本%@",[BUAdSDKManager SDKVersion]);
    //穿山甲小说
    //[self configNovel];
//    LCDConfig *lcdconfig = [LCDConfig new];
//    lcdconfig.logLevel = LCDSDKLogLevelDebug;
//    NSString *configPath = [[NSBundle mainBundle] pathForResource:@"SDK_Setting" ofType:@"json"];
//    [LCDManager startWithConfigPath:configPath config:lcdconfig completion:^(LCDINITStatus initStatus) {
//        if (initStatus == LCDINITStatus_success) {
//            NSLog(@"初始化注册成功！");
//        } else {
//            NSLog(@"初始化注册失败，请重新注册");
//        }
//    }];
    //腾讯广点通
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //腾讯广点通
        BOOL result = [GDTSDKConfig registerAppId:@"1111094678"];
        if (result) {
            NSLog(@"注册成功");
        }
    });
    
    //金丝雀初始化
    [CXHAdSDK setRequestDomain:@"http://ad.baihemob.com"];
    [CXHAdSDK initWithAppId:@"794231" completionBlock:^(NSError * _Nullable error) {
    if (error) {
    NSLog(@"初始化失败金丝雀:%@", error);
     }
    }];
    
    //快手SDK初始化
    NSString *appId = @"603000003";
    [KSAdSDKManager setAppId:appId];
    [KSAdSDKManager setLoglevel:KSAdSDKLogLevelOff];
    NSString *s= [KSAdSDKManager SDKVersion];
    NSLog(@"快手%@",s);
    
    // 小满初始化
    [BXMediaCenterSDK setDebugLog:YES];
    [BXMediaCenterSDK setAppKey:@"kksh-IOS-hdgj_xsekjn" secretKey:@"3DlW2J3WeglE03j6"];
    NSLog(@"%@",[BXMediaCenterSDK getSDKVersion]);
    
    
    //变现猫初始化
    [DHCWSDKConfig configManagerAppId:@"3daa9a4d0dc14583b9963761b0bfc8e5"];
    
    
    [self initFantai];
    
    //友盟
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [UMConfigure initWithAppkey:@"5ec4f0e3167edd5cfd000387" channel:@"App Store"];
        
        [UMSocialGlobal shareInstance].universalLinkDic = @{@(UMSocialPlatformType_WechatSession):@"https://h5.weface.com.cn/kankanlife/"};
        
        [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:WXAppId appSecret:WXAppSecret redirectURL:@"https://h5.weface.com.cn/kankanlife/"];
        
    });
    
//    //向微信注册
//    [WXApi registerApp:WXAppId universalLink:@"https://h5.weface.com.cn/kankanlife/"];
//
//
    //防止push时,tabbar出现
//    [[UITabBar appearance] setTranslucent:NO];

    //个数
    [GTCountSDK startSDKWithAppId:kGcAppId withChannelId:@"appstore"];
    
    // 通过个推平台分配的appId、 appKey 、appSecret 启动SDK，注：该方法需要在主线程中调用
    [GeTuiSdk startSdkWithAppId:kGcAppId appKey:kGcAppKey appSecret:kGcAppSecret delegate:self launchingOptions:launchOptions];

    // 注册远程通知
    [GeTuiSdk registerRemoteNotification: (UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)];
    
    // 通过个推平台分配的appId、 appKey 、appSecret 启动SDK，注：该方法需要在主线程中调用
    //[GeTuiSdk startSdkWithAppId:kGcAppId appKey:kGcAppKey appSecret:kGcAppSecret delegate:self];
//    [GeTuiSdk registerRemoteNotification:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)];
   
    
    //百度地图初始化
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    
        [[BMKLocationAuth sharedInstance] checkPermisionWithKey:BaiDuMap_AK authDelegate:self];
        
    });

//    NSString *idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
//    NSLog(@"hahahahahaha=%@",idfa);
//     NSString * IDFV = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
//     NSLog(@"hahahahahaha：%@",IDFV);

    //Bugly
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    
        if ([@"https://socialsecurity.weface.com.cn:8066" isEqualToString:IPDIZHI]) {
            [Bugly startWithAppId:@"06236897d0"];
        }
        
    });
    //mob一键登录
    [MobSDK uploadPrivacyPermissionStatus:YES onResult:^(BOOL success) {
    //注意业务逻辑不要依赖于这个success结果，建议业务逻辑在调用这个接口之后来写
    }];
    [MobSDK registerAppKey:@"38b797dbbf6ec" appSecret:@"05883c7b9185edb99a6ded653cfe3e39"];
    //推送环境,生产
    [MobPush setAPNsForProduction:YES];
    //MobPush推送设置（获得角标、声音、弹框提醒权限）
    MPushNotificationConfiguration *configuration = [[MPushNotificationConfiguration alloc] init];
    configuration.types = MPushAuthorizationOptionsBadge | MPushAuthorizationOptionsSound | MPushAuthorizationOptionsAlert;
    [MobPush setupNotification:configuration];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMessage:) name:MobPushDidReceiveMessageNotification object:nil];
    
    [MobPush getRegistrationID:^(NSString *registrationID, NSError *error) {

     NSLog(@"registrationID = %@--error = %@", registrationID, error);

    }];
    //极光统计
    JANALYTICSLaunchConfig * config = [[JANALYTICSLaunchConfig alloc] init];
    config.appKey = appKey;
    config.channel = channel;
    [JANALYTICSService setupWithConfig:config];
    [JANALYTICSService setDebug:isProduction];

    
    //[SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeFlat];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeGradient];
    [SVProgressHUD setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0]];

    ////雷俊博注释
//    [logNetModel getLogMessage3:nil andTelephone:self.telephoneLoginStr andLoginpassword:self.telephoneLoginPassport  andUid:nil andl:0 andweixinId:nil andPicId:nil completionHandle:^(lodModel *model, NSError *error) {
//        if (error ) {
//
//        }
//        dispatch_async(dispatch_get_main_queue(), ^{
//            if(model.userinfo.account_type == 0)  [getPeopleID getLimmitedToBanbana:YES];else
//                [getPeopleID getLimmitedToBanbana:NO];
//        });
//    }];
    [getPeopleID getLimmitedToBanbana:YES];
    [application setApplicationIconBadgeNumber:0];
    self.isLogin = NO;
    self.isHuoti = NO;
    self.isTel = NO;
    [getPeopleID getSocialSecurityProvinceData:@"上海市" andCountry:@"市辖区" andOther:@"浦东新区"];
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        [getPeopleID deletePlist];
        [getPeopleID createPlistByCode];
        [[NSUserDefaults standardUserDefaults] setInteger:80 forKey:@"fucck"];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firdfghjefhrju"];
        [[NSUserDefaults standardUserDefaults]synchronize];
        [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"fucck_two"];
        [[NSUserDefaults standardUserDefaults]synchronize];
      [self baiduFaceReCo];
    
    KKNavViewController* mainNav = [[KKNavViewController alloc]initWithRootViewController:self.tabVC];
    mainNav.navigationBarHidden = YES;
    if(![[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]){
        //第一次进引导页
        [getPeopleID createPlistByCode];
        [[NSUserDefaults standardUserDefaults] setInteger:80 forKey:@"fucck"];
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstlog"];
        //雷俊博注释:目前没什么用
       // [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"zhifubaAlibaba"];
        [getPeopleID socialSate:0];
//        UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
//        uitableViewController *tc=[sb instantiateViewControllerWithIdentifier:@"uitableViewController"];
        self.showSplashWhenBecomeActive = YES;
        XLJNewFetureController *newVC = [[XLJNewFetureController alloc] initWithNSArray:self.mArray withButtonSize:CGSizeMake([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width) withButtonTitle:@" " withButtonImage:nil withButtonTitleColor:[UIColor orangeColor] withButtonHeight:0.73 withViewController:mainNav];
        KKNavViewController*nav = [[KKNavViewController alloc]initWithRootViewController:newVC];
        self.window.rootViewController = nav;
        [self.window makeKeyAndVisible];
    }else{
        self.showSplashWhenBecomeActive = YES;
        //设置window的根视
        self.window.rootViewController = mainNav;
        //设置guangao
//        UINavigationController* nav = [[UINavigationController alloc]initWithRootViewController:self.pageVC];
//        nav.navigationBarHidden = YES;
//
//        self.window.rootViewController = nav;
        UIImageView* lauchImageView = [[UIImageView alloc]init];
        lauchImageView.image = [UIImage imageNamed:[self getCurrentLaunchImageNameForOrientation:UIInterfaceOrientationPortrait]];
        lauchImageView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
        self.lauchImageView = lauchImageView;
        [self.window makeKeyAndVisible];
        [self.window addSubview:lauchImageView];
        bool openAppSpalsh=[UserDefault boolForKey:@"openAppSpalsh"];
        if(openAppSpalsh){
            [self showWhatTypeAD];
            [self.adRequest startRequestAdType];
//            [self addStartPageVC];
//            [self.pageVC loadMyAdData];
            [UserDefault setBool:NO forKey:@"openAppSpalsh"];
        }else{
            [self addStartPageVC];
            [self.pageVC loadMyAdData];
            [UserDefault setBool:YES forKey:@"openAppSpalsh"];
        }
//        if (@available(iOS 9.0,*)) {
//            [self showWhatTypeAD];
//            [self.adRequest startRequestAdType];
//        }else{
//            [self addStartPageVC];
//            [self.pageVC loadMyAdData];
//        }
    }
    [self dianchi];
    

    

    //键盘
      [IQKeyboardManager sharedManager].enable = YES;
      [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
      [[IQKeyboardManager sharedManager]setEnableAutoToolbar:NO];
    
    //药兜网
    [YDAuthenticationHelper registerApp:@"Kankan"];
    
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //喜马拉雅
        [[XMReqMgr sharedInstance] registerXMReqInfoWithKey:XMAppKey appSecret:XMAppSecret];
        [XMReqMgr sharedInstance].delegate = self;
    });
    
    
      
     //注册响应后台控制
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];

    
    // 骨架屏core部分不依赖reveal工具
    // reveal工具依赖骨架屏core，实时预览效果，无需编译
   // [[TABAnimatedBall shared] install];

    // Init `TABAnimated`, and set the properties you need.
    // 初始化TABAnimated，并设置TABAnimated相关属性
    // 初始化方法仅仅设置的是全局的动画效果
    // 你可以设置`TABViewAnimated`中局部动画属性`superAnimationType`覆盖全局属性，在工程中兼容多种动画
    [[TABAnimated sharedAnimated] initWithOnlySkeleton];
    // open log
    // 开启日志
    [TABAnimated sharedAnimated].openLog = YES;
    // set gobal cornerRadius
    [TABAnimated sharedAnimated].useGlobalCornerRadius = NO;
    // 是否开启动画坐标标记，如果开启，也仅在debug环境下有效。
    // 开启后，会在每一个动画元素上增加一个红色的数字，该数字表示该动画元素所在下标，方便快速定位某个动画元素。
    [TABAnimated sharedAnimated].openAnimationTag = YES;
    

    return YES;
}

// 收到通知回调
- (void)didReceiveMessage:(NSNotification *)notification{
    MPushMessage *message = notification.object;
         // 推送相关参数获取示例请在各场景回调中对参数进行处理
              NSString *body = message.notification.body;
          NSString *title = message.notification.title;
          NSString *subtitle = message.notification.subTitle;
          NSInteger badge = message.notification.badge;
          NSString *sound = message.notification.sound;
    NSDictionary *userinfo=message.notification.userInfo;
          NSLog(@"收到通知:{\nbody:%@，\ntitle:%@,\nsubtitle:%@,\nbadge:%ld,\nsound:%@,\nuserinfo:%@}",body, title, subtitle, (long)badge, sound,userinfo);
    switch (message.messageType){
        case MPushMessageTypeCustom:{// 自定义消息回调
            NSLog(@"自定义消息回调%@",message);
        }
            break;
        case MPushMessageTypeAPNs:{// APNs回调
            NSLog(@"APNs回调%@",message);
        }
            break;
        case MPushMessageTypeLocal:{// 本地通知回调
            NSLog(@"本地通知回调%@",message);
        }
            break;
        case MPushMessageTypeClicked:{// 点击通知回调
            NSLog(@"点击通知回调%@",message);
            @try {
                NSString *pushurl=userinfo[@"url"];
                NSString *pushtype=userinfo[@"push_type"];
                [[NSUserDefaults standardUserDefaults]setObject:pushurl forKey:@"mob_pushUrl"];
                [[NSUserDefaults standardUserDefaults]setObject:pushtype forKey:@"mob_pushType"];
                [[NSNotificationCenter defaultCenter]postNotificationName:KKSBGTPushNotificationName object:nil userInfo:nil];
            } @catch (NSException *exception) {
                NSLog(@"%@",exception);
            }
        }
        default:
            break;
    }
}


#pragma mark - 登录通知绑定方法
- (void)checkJumpToLoginVC:(NSNotification *)noti
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
     
     if (![[NSUserDefaults standardUserDefaults]boolForKey:@"firstlog"]){
         
         NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
         
         if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

             NSString* uid = [UserDefault objectForKey:@"appleId"];
             NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
             NSString* cus_name = [getPeopleID Peopletitle];
             NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
             
             
             BPViewController *bpVC = [[BPViewController alloc]init];
             bpVC.UID = uid;
             bpVC.Id = userId;
             bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
             bpVC.wxPhotoUrl = photoUrl;
             bpVC.title = @"绑定手机号";
             bpVC.from = @"other";
             UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
             
             [nav1 presentViewController:nav animated:YES completion:nil];
             
             return;

         }
         
         LoginVC *loginVC = [[LoginVC alloc]init];
         
         self.loginShow = YES;
         self.loginVC = loginVC;
         UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
         [nav1 presentViewController:nav animated:YES completion:nil];
         
         
         return;
     }
     
}

#pragma mark - 获取启动图页面

-(NSString *)getCurrentLaunchImageNameForOrientation:(UIInterfaceOrientation)orientation{
    NSString *currentImageName = nil;

    CGSize viewSize = CGSizeMake(ScreenWidth, ScreenHeight);
    NSString* viewOrientation = @"Portrait";

    if(UIInterfaceOrientationIsLandscape(orientation)){
        viewSize = CGSizeMake(viewSize.height, viewSize.width);
        viewOrientation = @"Landscape";
    }
    
    NSArray *imageDicts = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary * dic in imageDicts) {
        CGSize imageSize = CGSizeFromString(dic[@"UILaunchImageSize"]);　//将字符串转换为Size
        NSString *orientation = dic[@"UILaunchImageOrientation"];　//取得方向
        if(CGSizeEqualToSize(viewSize, imageSize) && [orientation isEqualToString:viewOrientation]){
            currentImageName = dic[@"UILaunchImageName"];
        }
    }
    
    return currentImageName;
}

#pragma mark - 显示什么类型广告

- (void)showWhatTypeAD{
    NSInteger factoryIndex = [[NSUserDefaults standardUserDefaults]integerForKey:@"adType"];
     CTAdType type = CTAdTypeTengXun;
    if (factoryIndex == 1001004){
        type = CTAdTypeChuanShanJia;
    }else if (factoryIndex == 1001005){
        type = CTAdTypeTengXun;
    }else if (factoryIndex == 1001007){
        type = CTAdTypeKuaiShou;
        self.showKuaishou = YES;
    }else if (factoryIndex == 1001001){
        type = CTAdTypeADmobile;
    }
    [self loadAdTypeApiSuccessWithAdType:type adName:nil adIndex:nil];
}


#pragma mark -锁屏回调
- (void)remoteControlReceivedWithEvent:(UIEvent *)event
{
    if (event.type != UIEventTypeRemoteControl) {
        return;
    }
    NSLog(@"remoteControlReceivedWithEvent---");
    if (event.subtype == UIEventSubtypeRemoteControlPause) {
        [[XMSDKPlayer sharedPlayer] pauseTrackPlay];
//        [[XMSDKPlayer sharedPlayer] pauseLivePlay];
    } else if (event.subtype == UIEventSubtypeRemoteControlPlay) {
        [[XMSDKPlayer sharedPlayer] resumeTrackPlay];
//        [[XMSDKPlayer sharedPlayer] resumeLivePlay];
    } else if (event.subtype == UIEventSubtypeRemoteControlTogglePlayPause) {
        [[XMSDKPlayer sharedPlayer] pauseTrackPlay];
    }else if (event.subtype == UIEventSubtypeRemoteControlPreviousTrack){
        [[XMSDKPlayer sharedPlayer] playPrevTrack];
        XMTrack*track = [XMSDKPlayer sharedPlayer].currentTrack;
        [self setupLockScreenMediaInfo:track];
    }else if (event.subtype == UIEventSubtypeRemoteControlNextTrack){
        [[XMSDKPlayer sharedPlayer] playNextTrack];
        XMTrack*track = [XMSDKPlayer sharedPlayer].currentTrack;
        [self setupLockScreenMediaInfo:track];
    }
}


#pragma mark - 锁频控制
//更新通知中心控制台媒体信息
- (void)setupLockScreenMediaInfo:(XMTrack *)track {
    
    MPNowPlayingInfoCenter *playingCenter = [MPNowPlayingInfoCenter defaultCenter];
    
    NSMutableDictionary *playingInfo = [NSMutableDictionary new];
    //标题
    playingInfo[MPMediaItemPropertyTitle]      = track.trackTitle;
    //封面图片
    UIImage *coverImage = nil;
    if ([NSString blankString:track.coverUrlLarge]) {
        coverImage = [UIImage imageNamed:@"logo"];
    }else {
        UIImageView *coverImageView = [[UIImageView alloc] init];
        [coverImageView sd_setImageWithURL:[NSURL URLWithString:track.coverUrlSmall]];
        coverImage = coverImageView.image;
        if (coverImage == nil) {
            coverImage = [UIImage imageNamed:@"logo"];
        }
    }
    MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc] initWithImage:coverImage];
    playingInfo[MPMediaItemPropertyArtwork] = artwork;
    
    // 当前播放的时间
    NSLog(@"playingInfo . currentTime = %f",track.duration / 1000.0);
    playingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = [NSNumber numberWithFloat:100 / 1000];
    // 进度的速度
    playingInfo[MPNowPlayingInfoPropertyPlaybackRate] = [NSNumber numberWithFloat:1.0];
    // 总时间
    playingInfo[MPMediaItemPropertyPlaybackDuration] = [NSNumber numberWithFloat:track.duration / 1000];
//    if (@available(iOS 10.0, *)) {
//        playingInfo[MPNowPlayingInfoPropertyPlaybackProgress] = [NSNumber numberWithFloat:self.audioControlView.progress];
//    } else {
//        // Fallback on earlier versions
//    }
    [playingCenter setNowPlayingInfo:playingInfo];
}
#pragma mark - 显示主页面

- (void)setupUI:(BOOL)success
{
//    UINavigationController* mainNav = [[UINavigationController alloc]initWithRootViewController:self.tabVC];
//    mainNav.navigationBarHidden = YES;
//
//    self.window.rootViewController = mainNav;
    //[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
    
    if (self.pageVC.view.superview) {
        [self.pageVC removeFromParentViewController];

        [self.pageVC.view removeFromSuperview];
    }
    [self.lauchImageView removeFromSuperview];
}
#pragma mark - 添加闪屏页到根视图上
- (void)addStartPageVC
{
//    KKNavViewController *nav = (KKNavViewController *)self.window.rootViewController;
    
    //[nav addChildViewController:self.pageVC];
    [self.window addSubview:self.pageVC.view];
    
    self.pageVC.view.bounds = ScreenBounds;
}




#pragma mark - 广告
//优量汇
- (void)creatTXSplash{
    //开屏广告初始化并展示代码
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        GDTSplashAd *splash = [[GDTSplashAd alloc] initWithPlacementId:@"2041337653782800"];
        splash.delegate = self;
        splash.fetchDelay = 10;
        UIImage *splashImage = [UIImage imageNamed:@"SplashNormal"];
//        if (isIPhoneXSeries()) {
//
//        } else if ([UIScreen mainScreen].bounds.size.height == 480) {
//            splashImage = [UIImage imageNamed:@"SplashSmall"];
//        }
        splashImage = [UIImage imageNamed:@"SplashX"];
        splash.backgroundImage = splashImage;
        
        self.txSplash = splash;
        
        [self.txSplash loadAd];
    }
}

//加载穿山甲gromore
-(void)initAdGromore{
    //穿山甲gromore初始化
    BUAdSDKConfiguration *configuration = [BUAdSDKConfiguration configuration];
     //设置APPID
    configuration.appID = @"5109638";
     //是否使用聚合
    configuration.useMediation = YES;
    // SDK异步初始化
    [BUAdSDKManager startWithAsyncCompletionHandler:^(BOOL success, NSError *error) {
      if (success) {
          NSLog(@"穿山甲聚合gromore成功:%@",[BUAdSDKManager SDKVersion]);
          
          BUAdSlot *slot = [[BUAdSlot alloc]init];
          slot.ID = @"102948245";
          
          BUSplashAd *splashAd = [[BUSplashAd alloc] initWithSlot:slot adSize:CGSizeZero];
          splashAd.delegate = self;
          self.splashAd = splashAd;
          
          CGFloat bottomViewHeight;
          if (TARGET_IPHONE_X) { // 刘海屏
              bottomViewHeight = [UIScreen mainScreen].bounds.size.height * 0.15;
          } else {
              bottomViewHeight = [UIScreen mainScreen].bounds.size.height - [UIScreen mainScreen].bounds.size.width * (960 / 640.0);
          }
          UIView *bottomView = [[UIView alloc] init];
          bottomView.backgroundColor = [UIColor whiteColor];
          bottomView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, bottomViewHeight);
          UIImageView *logoImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_ad_bottomView.png"]];
          logoImageView.frame = CGRectMake(0, (bottomViewHeight-130)/2, ScreenWidth, 130);
          [bottomView addSubview:logoImageView];
          
          self.splashAd.mediation.customBottomView = bottomView;
          [self.splashAd loadAdData];
      }else{
          NSLog(@"穿山甲聚合gromore失败:%@",[BUAdSDKManager SDKVersion]);
          [self.lauchImageView removeFromSuperview];
      }
    }];
    

    
}

/******** gromore开屏广告回调处理 *********/
#pragma mark - BUMSplashAdDelegate
// 加载成功
- (void)splashAdLoadSuccess:(nonnull BUSplashAd *)splashAd {
    NSLog(@"穿山甲gromore_:%@",@"splashAdLoadSuccess");
    // 使用应用keyWindow的rootViewController（接入简单，推荐）
    //        NSLog(@"self.lauchImageView.superview:%@",self.lauchImageView.superview);
            [self setupUI:YES];
           UIWindow *keyWindow = self.window;
            //[keyWindow.rootViewController.view addSubview:self.splashView1];
    //        self.splashView1.rootViewController = keyWindow.rootViewController;
    //        NSLog(@"self.lauchImageView.superview:%@",self.lauchImageView.superview);
    [self.window bringSubviewToFront:self.lauchImageView];
    [self.lauchImageView removeFromSuperview];
    [splashAd showSplashViewInRootViewController:keyWindow.rootViewController];
}

// 加载失败
- (void)splashAdLoadFail:(nonnull BUSplashAd *)splashAd error:(BUAdError * _Nullable)error {
    NSLog(@"穿山甲gromore_splashAdLoadFail:%@",error);
    [self.lauchImageView removeFromSuperview];
}

// 广告即将展示
- (void)splashAdWillShow:(nonnull BUSplashAd *)splashAd {
    NSLog(@"穿山甲gromore:%@",@"splashAdWillShow");
}

// 广告被点击
- (void)splashAdDidClick:(nonnull BUSplashAd *)splashAd {
    NSLog(@"穿山甲gromore:%@",@"splashAdDidClick");
    [self removeSplashAdView];
    [self.bottom removeFromSuperview];
}

// 广告被关闭
- (void)splashAdDidClose:(BUSplashAd *)splashAd closeType:(BUSplashAdCloseType)closeType {
    // 按照实际情况决定是否销毁广告对象
    NSLog(@"穿山甲gromore:%@",@"splashAdDidClose");
    [splashAd.mediation destoryAd];
}

// 广告展示失败
- (void)splashAdDidShowFailed:(BUSplashAd *_Nonnull)splashAd error:(NSError *)error {
    NSLog(@"穿山甲gromore:splashAdDidShowFailed%@",error);
}




//快手开屏广告
- (void)loadKSSplashAdView
{
    //􏰛􏰜􏰝􏱁􏰵􏰂􏰃
    self.ksSplashAdView = [[KSSplashAdView alloc] initWithPosId:@"6030000040"];
    self.ksSplashAdView.delegate = self;
    //􏰣􏰤􏰮􏰯5s􏱩􏱪􏰅􏱫􏱬
    self.ksSplashAdView.needShowMiniWindow = NO;
    
    self.ksSplashAdView.timeoutInterval = 7;
    
    self.ksSplashAdView.rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
    
    CGFloat bottomViewHeight = 0;

     if (cl_kNavigationBarHeight > 64) {
         bottomViewHeight = 180 * WIDTHRADIU;
     }else{
         bottomViewHeight = 150 * WIDTHRADIU;
     }
    
    self.ksSplashAdView.frame = CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height - bottomViewHeight);
    self.ksSplashAdView.backgroundColor = [UIColor whiteColor];
    
    //􏱭􏰧􏱁􏰵􏰂􏰃
    [self.ksSplashAdView loadAdData];
}

#pragma mark - CTShowAdTypeQuestDelegate
- (void)loadAdTypeApiSuccessWithAdType:(CTAdType)type adName:(NSString *)name adIndex:(NSInteger)index{
    CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
    
    self.start = start;
    [[NSUserDefaults standardUserDefaults]setObject:@(Tools.getNowTimeTimesLong) forKey:@"app_open_time"];
    if (_showAd) {
        [self addStartPageVC];
        [self.pageVC loadMyAdData];
    }else{
        if (type == CTAdTypeChuanShanJia){
            //[self creatTXSplash];
            [self initAdGromore];
           [[NSUserDefaults standardUserDefaults]setObject:[NSDate date] forKey:@"LastADShowTime"];
           [[NSUserDefaults standardUserDefaults]synchronize];
       }else if (type == CTAdTypeTengXun){
           //[self creatTXSplash];
           [self initAdGromore];
           //[self setupBUAdSDK];
           [GTCountSDK trackCountEvent:@"AD_tengxun_request" withArgs:@{}];
           [[NSUserDefaults standardUserDefaults]setObject:[NSDate date] forKey:@"LastADShowTime"];
           [[NSUserDefaults standardUserDefaults]synchronize];
       }else if (type == CTAdTypeKuaiShou){
           self.showKuaishou = YES;
           [self loadKSSplashAdView];
       }else if (type == CTAdTypeADmobile){
           [self creatTXSplash];
           [GTCountSDK trackCountEvent:@"ADmobile_request" withArgs:@{}];
           [NetworkRequest statisticsWithEventName:@"ADmobile_request"];
       }else{
           [self addStartPageVC];
           [self.window bringSubviewToFront:self.lauchImageView];
           
           [self.pageVC loadMyAdData];
       }
    }
     
}


//初始化凡泰
- (void)initFantai{
    NSMutableArray *storeArrayM = [NSMutableArray array];
    FATStoreConfig *storeConfig = [[FATStoreConfig alloc] init];
    storeConfig.sdkKey = @"4hBu7NHaKNt2cn/bFb67Ykb0aDmUmHocUrUneUtkcpY=";
    storeConfig.sdkSecret = @"d6a5cf3ebcb75a35";
    storeConfig.apiServer = @"https://api.finclip.com";
    storeConfig.apmServer = @"https://api.finclip.com";
    storeConfig.cryptType = FATApiCryptTypeMD5;
    [storeArrayM addObject:storeConfig];
     //安信生产
    FATStoreConfig *storeConfig2 = [[FATStoreConfig alloc] init];
    storeConfig2.sdkKey = @"4hBu7NHaKNt2cn/bFb67YvPgwRmw88oGAHmqCTzqlUQ=";
    storeConfig2.sdkSecret = @"aae31f4b555a93af";
    storeConfig2.apiServer = @"https://axzqgf-kksh-zl.fdep.cn";
    storeConfig2.apmServer = @"https://open.fdep.cn";
    storeConfig2.cryptType = FATApiCryptTypeSM;
    storeConfig2.fingerprint=@"1042F59D2F80487BE33C377470F2DEAF392A9F57F1CDE1653363FAC4A3274968";
    [storeArrayM addObject:storeConfig2];
    //安信测试
    FATStoreConfig *storeConfig3 = [[FATStoreConfig alloc] init];
    storeConfig3.sdkKey = @"4hBu7NHaKNt2cn/bFb67Ykb0aDmUmHocUrUneUtkcpY=";
    storeConfig3.sdkSecret = @"d6a5cf3ebcb75a35";
    storeConfig3.apiServer = @"https://api.finclip.com";
    storeConfig3.apmServer = @"https://api.finclip.com";
    storeConfig3.cryptType = FATApiCryptTypeSM;
    //storeConfig3.fingerprint=@"1042F59D2F80487BE33C377470F2DEAF392A9F57F1CDE1653363FAC4A3274968";
    [storeArrayM addObject:storeConfig3];
    // 创金合信测试
    FATStoreConfig *storeConfigT = [[FATStoreConfig alloc] init];
    storeConfigT.sdkKey = @"4hBu7NHaKNt2cn/bFb67Ykb0aDmUmHocUrUneUtkcpY=";
    storeConfigT.sdkSecret = @"d6a5cf3ebcb75a35";
    storeConfigT.apiServer = @"https://api.finclip.com";
    storeConfigT.apmServer = @"https://api.finclip.com";
    storeConfigT.cryptType = FATApiCryptTypeMD5;
    //storeConfig3.fingerprint=@"1042F59D2F80487BE33C377470F2DEAF392A9F57F1CDE1653363FAC4A3274968";
    [storeArrayM addObject:storeConfigT];
    // 创金合信
    FATStoreConfig *storeConfig4 = [[FATStoreConfig alloc] init];
    storeConfig4.sdkKey = @"4hBu7NHaKNt2cn/bFb67YvPgwRmw88oGAHmqCTzqlUQ=";
    storeConfig4.sdkSecret = @"aae31f4b555a93af";
    storeConfig4.apiServer = @"https://cjhxjj-kksh-zl.fdep.cn";
    storeConfig4.apmServer = @"https://open.fdep.cn";
    storeConfig4.cryptType = FATApiCryptTypeMD5;
    //storeConfig3.fingerprint=@"1042F59D2F80487BE33C377470F2DEAF392A9F57F1CDE1653363FAC4A3274968";
    [storeArrayM addObject:storeConfig4];

    FATUIConfig *uiconfig=[[FATUIConfig alloc] init];
    uiconfig.hideForwardMenu=YES;
    uiconfig.hideShareAppletMenu=YES;
    
    
    FATConfig *ftconfig = [FATConfig configWithStoreConfigs:storeArrayM];
    [[FATClient sharedClient] initWithConfig:ftconfig uiConfig:uiconfig error:nil];

    //电子社保卡
    SSCSDKConfig *config = [[SSCSDKConfig alloc] init];
    config.appHost=PRODUCTIONHOST;
    NSString *essVersion=[[SSCPublicHeader sharedSSCTool] sSDKVesrion];
    NSLog(@"电子社保卡版本号:%@",essVersion);
    [[SSCPublicHeader sharedSSCTool] initSDKWithAppConfig:config];
    
}



- (void)removeSplashAdView {
//    if (self.splashView1) {
//        [self.splashView1 removeFromSuperview];
//        self.splashView1 = nil;
//    }
}

/**
 This method is called when splash ad material loaded successfully. 穿山甲和优量汇共用
 */
- (void)splashAdDidLoad:(id)splashAd{
        if ([splashAd isKindOfClass:[GDTSplashAd class]]){
        [self setupUI:YES];
        [self.txSplash showAdInWindow:self.window withBottomView:self.bottom skipView:nil];
        [self.lauchImageView removeFromSuperview];
    }
}


#pragma mark - GDTSplashAdDelegate
/**
 *  开屏广告成功展示
 */
- (void)splashAdSuccessPresentScreen:(GDTSplashAd *)splashAd
{
    NSLog(@"%s",__FUNCTION__);
    
    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
    self.end = end;
    
    NSLog(@"cost:%f",self.end - self.start);
//    NSString *timeText = [NSString stringWithFormat:@"显示广告花掉的时间:%.2f",self.end - self.start];
//    [[KSBulletScreenManager sharedInstance] showWithText:timeText];
}


/**
 *  开屏广告展示失败
 */
- (void)splashAdFailToPresent:(GDTSplashAd *)splashAd withError:(NSError *)error
{
    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
    self.end = end;
    
    NSLog(@"cost:%f",self.end - self.start);
    
//    NSString *timeText = [NSString stringWithFormat:@"显示广告花掉的时间:%.2f",self.end - self.start];
//    [[KSBulletScreenManager sharedInstance] showWithText:timeText];
    
    NSLog(@"%s",__FUNCTION__);
    
    
    [self addStartPageVC];
    [self.window bringSubviewToFront:self.lauchImageView];
    
    [self.pageVC loadMyAdData];
}


/**
 *  开屏广告点击回调
 */
- (void)splashAdClicked:(GDTSplashAd *)splashAd
{
    //[[NSNotificationCenter defaultCenter] postNotificationName:KKSBChangeToHomeVCNotificationName object:nil userInfo:nil];
}

/**
 *  开屏广告将要关闭回调
 */
- (void)splashAdWillClosed:(GDTSplashAd *)splashAd
{
   // [[NSNotificationCenter defaultCenter] postNotificationName:KKSBChangeToHomeVCNotificationName object:nil userInfo:nil];
}

/**
 *  开屏广告关闭回调
 */
- (void)splashAdClosed:(GDTSplashAd *)splashAd
{
    
}

/**
 *  开屏广告点击以后即将弹出全屏广告页
 */
- (void)splashAdWillPresentFullScreenModal:(GDTSplashAd *)splashAd
{
    
}

/**
 *  开屏广告点击以后弹出全屏广告页
 */
- (void)splashAdDidPresentFullScreenModal:(GDTSplashAd *)splashAd
{
    
}

/**
 *  点击以后全屏广告页将要关闭
 */
- (void)splashAdWillDismissFullScreenModal:(GDTSplashAd *)splashAd
{
    
}

/**
 *  点击以后全屏广告页已经关闭
 */
- (void)splashAdDidDismissFullScreenModal:(GDTSplashAd *)splashAd
{
    
}



#pragma mark - KSSplashAdViewDelegate
/**
 * splash ad request done
 */
- (void)ksad_splashAdDidLoad:(KSSplashAdView *)splashAdView
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
}
/**
 * splash ad material load, ready to display
 */
- (void)ksad_splashAdContentDidLoad:(KSSplashAdView *)splashAdView
{
    [self.lauchImageView removeFromSuperview];
    
    if (self.showKuaishou) {
        self.showKuaishou = NO;
        [self setupUI:YES];
    }
    
    self.ksSplashAdView.rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
    
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
    if ([[UIDevice currentDevice].systemVersion floatValue] < 10) {
        [self.ksSplashAdView showInView:self.window.rootViewController.view];
    } else {
        [self.ksSplashAdView showInView:self.window];
    }
    if ([[UIDevice currentDevice].systemVersion floatValue] < 10) {
        [self.window.rootViewController.view addSubview:self.bottom];
    } else {
        [self.window addSubview:self.bottom];
    }
}

/**
 * splash ad did visible
 */
- (void)ksad_splashAdDidVisible:(KSSplashAdView *)splashAdView
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
}

/**
 * splash ad video begin play
 * for video ad only
 */
- (void)ksad_splashAdVideoDidBeginPlay:(KSSplashAdView *)splashAdView
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
}

/**
 * splash ad (material) failed to load
 */
- (void)ksad_splashAd:(KSSplashAdView *)splashAdView didFailWithError:(NSError *)error
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
    [self removeksSplash];
    //[self.bottom removeFromSuperview];
    
    if (self.showKuaishou) {
        self.showKuaishou = NO;
        
        [self addStartPageVC];
        [self.window bringSubviewToFront:self.lauchImageView];
        
        [self.pageVC loadMyAdData];
    }else{
        [self.lauchImageView removeFromSuperview];
    }
  
}

/**
 * splash ad skipped
 * @param showDuration  splash show duration (no subsequent callbacks, remove & release KSSplashAdView here)
 */
- (void)ksad_splashAd:(KSSplashAdView *)splashAdView didSkip:(NSTimeInterval)showDuration
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
    if (!splashAdView.showingMiniWindow) {
        [self removeksSplash];
    }
    [self.bottom removeFromSuperview];
    
    //[self setupUI:YES];
}


/**
 * splash ad will zoom out, frame can be assigned
 * for video ad only
 * @param frame target frame
 */
- (void)ksad_splashAd:(KSSplashAdView *)splashAdView willZoomTo:(inout CGRect *)frame
{
    [self.bottom removeFromSuperview];
}

/**
 * splash ad clicked
 * @param inMiniWindow whether click in mini window
 */
- (void)ksad_splashAd:(KSSplashAdView *)splashAdView didClick:(BOOL)inMiniWindow
{
    //点击跳转了
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
    [self.bottom removeFromSuperview];
    
    //[self setupUI:YES];
}

/**
 * splash ad play finished & auto dismiss (no subsequent callbacks, remove & release KSSplashAdView here)
 */
- (void)ksad_splashAdDidAutoDismiss:(KSSplashAdView *)splashAdView
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
    [self removeksSplash];
    [self.bottom removeFromSuperview];
    //[self setupUI:YES];
}

/**
 * splash ad close by user (zoom out mode) (no subsequent callbacks, remove & release KSSplashAdView here)
 */
- (void)ksad_splashAdDidClose:(KSSplashAdView *)splashAdView
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
    [self removeksSplash];
    [self.bottom removeFromSuperview];
    //[self setupUI:YES];
}

/**
 * splash ad close conversion viewcontroller (no subsequent callbacks, remove & release KSSplashAdView here)
 */
- (void)ksad_splashAdDidCloseConversionVC:(KSSplashAdView *)splashAdView interactionType:(KSAdInteractionType)interactType
{
    //[[KSBulletScreenManager sharedInstance] showWithText:NSStringFromSelector(_cmd)];
    [self removeksSplash];
    [self.bottom removeFromSuperview];
    //[self setupUI:YES];
}
- (void)removeksSplash {
    if (self.ksSplashAdView.showingMiniWindow) {

[UIView animateWithDuration:.25f animations:^{
    self.ksSplashAdView.transform = CGAffineTransformMakeScale(0.1,0.1);
    self.ksSplashAdView.alpha = 0;
} completion:^(BOOL finished) {
    [self.ksSplashAdView removeFromSuperview];
    self.ksSplashAdView = nil;
    //[[NSNotificationCenter defaultCenter] postNotificationName:KKSBChangeToHomeVCNotificationName object:nil userInfo:nil];
}];
      } else {
          [self.ksSplashAdView removeFromSuperview];
          self.ksSplashAdView = nil;
          
          //[[NSNotificationCenter defaultCenter] postNotificationName:KKSBChangeToHomeVCNotificationName object:nil userInfo:nil];
} }



#pragma mark - private methods

//判断两个日期之间相差是否大于3分钟
- (BOOL)compareWithLastDate:(NSDate *)lastDate
{
    NSTimeInterval distanceBetweenDates = [[NSDate date] timeIntervalSinceDate:lastDate];
    distanceBetweenDates = fabs(distanceBetweenDates);
    NSInteger hoursBetweenDates = distanceBetweenDates / 60;

    if (hoursBetweenDates >= 3) {
        return YES;
    }else{
        return NO;
    }
}

// 判断是否是同一天
- (BOOL)isSameDay:(NSDate*)date1 date2:(NSDate*)date2
{
    NSCalendar* calendar = [NSCalendar currentCalendar];
    unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
    NSDateComponents* comp1 = [calendar components:unitFlags fromDate:date1];
    NSDateComponents* comp2 = [calendar components:unitFlags fromDate:date2];
    return [comp1 day] == [comp2 day] &&
    [comp1 month] == [comp2 month] &&
    [comp1 year] == [comp2 year];
}

- (void)saveOldDate
{
    NSDate *oldDate = [NSDate date];
    [[NSUserDefaults standardUserDefaults]setObject:oldDate forKey:@"chuanshanjiaSaveLastTime"];
    NSInteger count = [[NSUserDefaults standardUserDefaults]integerForKey:@"chuanshanjiaShowTimeToday"];
    [[NSUserDefaults standardUserDefaults]setInteger:count+1 forKey:@"chuanshanjiaShowTimeToday"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

- (void)clearCount
{
     [[NSUserDefaults standardUserDefaults]setInteger:0 forKey:@"chuanshanjiaShowTimeToday"];
     [[NSUserDefaults standardUserDefaults]synchronize];
}


#pragma mark - MYAdClickDelegate

/**
开屏展现
*/
- (void)MyAd_show:(MyAdViewController *)vc
{
    [self.lauchImageView removeFromSuperview];

    WeakSelf
    [self.tabVC presentViewController:vc animated:NO completion:^{
        [weakSelf.tabVC removeLun];
    }];
      [vc show];





   [vc.view addSubview:self.bottom];


    [CTAPIBaseManager GET3:ShengYangAdKaiPingCountUrl params:@{} completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {



       }];

    [GTCountSDK trackCountEvent:@"AD_shengyang" withArgs:@{}];
}
/**
开屏点击
*/
- (void)MyAd_Click:(NSDictionary *)dic vc:(nonnull MyAdViewController *)vc
{
    [vc dismissViewControllerAnimated:NO completion:^{
         [[NSNotificationCenter defaultCenter] postNotificationName:@"ZLPushToAdvert" object:nil userInfo:dic];
    }];
}

/**
开屏消失
*/
- (void)MyAd_DismissWithVC:(MyAdViewController *)vc
{
    [self.bottom removeFromSuperview];
    [vc dismissViewControllerAnimated:YES completion:nil];

}
/**
开屏请求失败
*/
- (void)MyAd_Fail:(MyAdViewController *)vc
{
     [self.pageVC loadMyAdData];
    [self.bottom removeFromSuperview];

}

#pragma mark - BMKLocationAuthDelegate
- (void)onCheckPermissionState:(BMKLocationAuthErrorCode)iError
{
    if (iError == BMKLocationAuthErrorSuccess) {
        NSLog(@"百度地图授权成功");
    }else{
         NSLog(@"百度地图授权失败");
    }
}

#pragma mark - XMReqDelegate
/* 初始化请求成功 */
-(void)didXMInitReqOK:(BOOL)result
{
    NSLog(@"initok");
}

/* 初始化请求失败 */
-(void)didXMInitReqFail:(XMErrorModel *)respModel
{
    NSLog(@"initfailed");
}

- (void)didXMPurchaseSucceed
{
    NSLog(@"支付成功");
}

- (void)didXMPurchaseFailWithError:(XMErrorModel *)error
{
    NSLog(@"支付失败");
}

- (void)didXMOpenPayFailWithError:(XMErrorModel *)error
{
    NSLog(@"didXMOpenPayFailWithError:%@", error);
}

- (void)didXMPurchaseViewBackByUser
{
    NSLog(@"didXMPurchaseViewBackByUser");
}

- (void)didXMPurchaseViewAppear
{
    NSLog(@"didXMPurchaseViewAppear");
}


#pragma mark - StartPageViewControllerDelegate
- (void)startPage_Show
{
    [self.lauchImageView removeFromSuperview];
    
}
- (void)startPage_Fail:(StartPageViewController *)vc
{
    //KKNavViewController *nav = (KKNavViewController *)self.window.rootViewController;
    
    [self setupUI:YES];
    [self.lauchImageView removeFromSuperview];
    
    //[[NSNotificationCenter defaultCenter] postNotificationName:KKSBChangeToHomeVCNotificationName object:nil userInfo:nil];
    
}
#pragma mark - 本地开屏页跳转
- (void)startPage_ClickWithModel:(UIViewController *)uiview eventParam:(NSString *)eventParam eventFlag:(NSString *) eventFlag{
    //KKNavViewController *nav = (KKNavViewController *)self.window.rootViewController;
    [[NSUserDefaults standardUserDefaults]setObject:eventParam forKey:@"eventParam_spalsh"];
    [[NSUserDefaults standardUserDefaults]setObject:eventFlag forKey:@"eventFlag_spalsh"];
    [self setupUI:YES];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"splashClickEvent" object:nil ];
//    if ([eventFlag isEqualToString:@"101"]) {//原生
//        [[clickEvent instance] clickEventRooterVC:uiview Content:eventParam menuName:@""];
//    }else if ([eventFlag isEqualToString:@"104"]){//H5
//        
//        WebVC *webvc = [[WebVC alloc]init];
//        webvc.url = eventParam;
//        webvc.title = @"";
//        webvc.hidesBottomBarWhenPushed = YES;
//        [uiview.navigationController pushViewController:webvc animated:YES];
//    }else if ([eventFlag isEqualToString:@"106"]){//联合登录
//        //[[clickEvent instance] clickEventRooterVC:nav getFederatedLoginRequestWithUrl:eventParam menuName:@""];
//        WebVC *webvc = [[WebVC alloc]init];
//                   webvc.url = @"http://www.baidu.com";
//                   webvc.title = @"";
//                   webvc.hidesBottomBarWhenPushed = YES;
//                   [uiview.navigationController pushViewController:webvc animated:YES];
//    }
    
//    if (![Tools isBlankString:model.targetUrl]) {
//        __block KKNavViewController *nav = (KKNavViewController *)self.window.rootViewController;
//
//        if([model.urlType intValue] == 104){
//            WebVC *webvc = [[WebVC alloc]init];
//            webvc.url = model.targetUrl;
//            webvc.title = model.title;
//            webvc.hidesBottomBarWhenPushed = YES;
//            [nav.navigationController pushViewController:webvc animated:YES];
//        }else if([model.urlType intValue] == 103){
//            if (![WXApi isWXAppInstalled]){
//                [Tools showMessage:@"请安装微信APP后重试"];
//                return;
//            }
//            if (model.title.length > 0 && model.targetUrl.length > 0) {
//                NSString *userName = model.title;
//                NSString *path = model.targetUrl;
//                WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
//                launchMiniProgramReq.userName = userName; //拉起的小程序的username
//                launchMiniProgramReq.path = path; //拉起小程序页面的可带参路径，不填默认拉起小程序首页
//                launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
//                [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
//
//                }];
//            }
//        }
//        [self setupUI:YES];
//    }
}

#pragma mark - SecondStartPageViewControllerDelegate
- (void)secondStartPage_ShowWithModel:(KKLogBannerModel *)model vc:(nonnull SecondStartPageViewController *)vc
{
    if ([model.eventflag isEqualToString:@"105"]) {
        [self.window addSubview:self.lauchImageView];
        [vc removeFromParentViewController];
        [vc.view removeFromSuperview];
        NSInteger factoryIndex = [[NSUserDefaults standardUserDefaults]integerForKey:@"adType"];
         CTAdType type = CTAdTypeChuanShanJia;
        if (factoryIndex == 1001004){
            type = CTAdTypeChuanShanJia;
        }else if (factoryIndex == 1001005){
            type = CTAdTypeTengXun;
        }else if (factoryIndex == 1001007){
            type = CTAdTypeKuaiShou;
        }else if (factoryIndex == 1001001){
            type = CTAdTypeADmobile;
        }
        
        [self loadAdTypeApiSuccessWithAdType:type adName:nil adIndex:nil];
    }else{
        [self.lauchImageView removeFromSuperview];
    }
}

#pragma mark - 二次开屏点击跳转
- (void)secondStartPage_ClickWithModel:(KKLogBannerModel *)model vc:(nonnull SecondStartPageViewController *)vc
{
//    [vc removeFromParentViewController];
//    [vc.view removeFromSuperview];
    if (model) {
        if (model.islogin) {
            __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
             
             if (![[NSUserDefaults standardUserDefaults]boolForKey:@"firstlog"]){
                 
                 NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
                 
                 if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

                     NSString* uid = [UserDefault objectForKey:@"appleId"];
                     NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
                     NSString* cus_name = [getPeopleID Peopletitle];
                     NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
                     
                     
                     BPViewController *bpVC = [[BPViewController alloc]init];
                     bpVC.UID = uid;
                     bpVC.Id = userId;
                     bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
                     bpVC.wxPhotoUrl = photoUrl;
                     bpVC.title = @"绑定手机号";
                     bpVC.from = @"other";
                     UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
                     [nav1 presentViewController:nav animated:YES completion:nil];
                     
                     return;

                 }
                 
                 LoginVC *loginVC = nil;
                 
                 if (self.loginShow) {
                     loginVC = self.loginVC;
                 }else{
                     loginVC = [[LoginVC alloc]init];
                 }
                 
                 WeakSelf
                 loginVC.block = ^(BOOL show) {
                     [weakSelf secondStartPage_ClickWithModel:model vc:vc];
                 };
                 if (!self.loginShow) {
                     UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
                     [nav1 presentViewController:nav animated:YES completion:nil];
                 }
                 return;
             }
        }
        
        switch (model.eventflag.integerValue) {
            case 101:
            {
                if (![Tools isBlankString:model.targeturl]) {
//                    NSDictionary* dic = [self dictionaryWithJsonString:model.eventparam];
//
//                    [self goToOtherVCWithDict:dic];
                    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
                    [[clickEvent instance] clickEventRooterVC:nav1 Content:model.targeturl menuName:model.title];
                    
                    return;
                }
                
                if ([model.title isEqualToString:@"找工作"]) {
                    
                    [self goToFindJobVC];
                }else if ([model.title isEqualToString:@"免费果园"]){
                    
                    [self goToFreeFruitVC];
                    
                }else if ([model.title isEqualToString:@"红包游戏"]){
                    
                }else if ([model.title isEqualToString:@"看视频赚金币"]){
                    
                    [self goToTVVC:YES];
                    
                }else if ([model.title isEqualToString:@"看视频赚红包"]){
                    [self goToTVVC:NO];
                }else if ([model.title isEqualToString:@"金币中心"]){
                    [self goToCoinCenterVC];
                }else if ([model.title isEqualToString:@"存钱罐"]){
//                    [self judgeSaveAmountRequest];
                    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
                    [[clickEvent instance] clickEventRooterVC:nav1 Content:@"homeThree4" menuName:model.title];
                }else if ([model.title isEqualToString:@"看新闻"]){
                    
                    [self goToNewsVC];
                    
                }else if ([model.title isEqualToString:@"我的钱包"]){
                    
                    [self goToMyWalletVC];
                    
                }else if ([model.title isEqualToString:@"金币排行榜"]){
                    
                    [self goToCoinRankVC];
                    
                }else if ([model.title isEqualToString:@"收益排行榜"]){
                    
                    [self goToAssetsRankVC];
                    
                }else if ([model.title isEqualToString:@"健康统计"]){
                    
                }else if ([model.title isEqualToString:@"金币抽奖"]){
                    
                    [self goToCoinRewardVC];
                    
                }else if ([model.title isEqualToString:@"我的奖品"]){
                    
                    [self goToMyPrizeListVC];
                    
                }else if ([model.title isEqualToString:@"邀请好友"]){
                    
                    [self goToInviteFriendsVC];
                    
                }else if ([model.title isEqualToString:@"社保认证"]){
                    
                    [self kkJumpUserIdentifyViewController];
                    
                }else if ([model.title isEqualToString:@"补贴认证"]){
                    [self goToBuTieVC];
                }else if ([model.title isEqualToString:@"医保卡"]){
                    [self goToYiBaoCardVC];
                }else if ([model.title isEqualToString:@"平价药房"]){
                    [self goToYaoDouVCWithLoginUrl:@"https://k.yaodouwang.com/"];
                }else if ([model.title isEqualToString:@"话费充值"]){
                    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
                    [[clickEvent instance] clickEventRooterVC:nav1 getFederatedLoginRequestWithUrl:model.targeturl menuName:model.title];
                }
            }
                break;
            case 102:
            {
                UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
                
                pasteboard.string = model.eventflag;
            
                [self openWechat];
            }
                break;
            case 103:
            {
                if (![WXApi isWXAppInstalled]){
                    [Tools showMessage:@"请安装微信APP后重试"];
                    return;
                }
                
                NSArray *array = [model.eventparam componentsSeparatedByString:@"@"];
                
                WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
                launchMiniProgramReq.userName = array[0];  //拉起的小程序的username
                launchMiniProgramReq.path = array[1];    //拉起小程序页面的可带参路径，不填默认拉起小程序首页
                launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
                [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
                    
                }];
            }
                break;
            case 104:
            {
                 __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
                 WebVC *webVC = [[WebVC alloc]init];
                 webVC.title = model.title;
                 webVC.url = model.targeturl;
                 webVC.hidesBottomBarWhenPushed =YES;
                 [nav1 pushViewController:webVC animated:YES];
            }
                break;
            case 105:
            {
                
            }
                break;
            default:
                break;
        }
    }
}

/**
显示自己的广告失败
*/
- (void)secondStartPage_Fail:(SecondStartPageViewController *)vc
{
    [vc removeFromParentViewController];
    [vc.view removeFromSuperview];
    
    [self.lauchImageView removeFromSuperview];
    
}

//字典转json
-(NSString *)convertToJsonData:(NSDictionary *)dict

{

     NSError *error;

    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];

    NSString *jsonString;

    if (!jsonData) {

        NSLog(@"%@",error);

    }else{

        jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];

    }

    

    return jsonString;

}


#pragma mark - getters and setters

- (MyAdViewController *)adVC
{
    if (!_adVC) {
        _adVC = [[MyAdViewController alloc]init];
        _adVC.delegate = self;
    }
    return _adVC;
}

- (tabViewController *)tabVC
{
    if (!_tabVC) {
        uitableViewController *tc=[Storyboard instantiateViewControllerWithIdentifier:@"uitableViewController"];
        tabViewController *TC =[[tabViewController alloc]init];
        TC.viewControllers =[NSArray arrayWithObjects:tc, nil];
        TC.tabBar.hidden =YES;
        _tabVC = TC;
    }
    return _tabVC;
}

- (StartPageViewController *)pageVC
{
    if (!_pageVC) {
        _pageVC = [StartPageViewController new];
        _pageVC.delegate = self;
    }
    return _pageVC;
}



- (UIView *)bottom
{
    if (!_bottom) {
        
        CGFloat bottomViewHeight = 0;
        
        if (cl_kNavigationBarHeight > 64) {
            bottomViewHeight = 180 * WIDTHRADIU;
        }else{
            bottomViewHeight = 150 * WIDTHRADIU;
        }
        
        _bottom = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight - bottomViewHeight, ScreenWidth, bottomViewHeight)];
        _bottom.backgroundColor = [UIColor whiteColor];
        UIImageView * backImageView = [[UIImageView alloc] init];
        backImageView.image = [UIImage imageNamed:@"logo_ad_bottomView_word"];
        backImageView.contentMode = UIViewContentModeScaleAspectFill;
        [_bottom addSubview:backImageView];
        
        [backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self->_bottom);
            
            make.centerX.equalTo(self->_bottom);
            make.centerY.equalTo(self->_bottom.mas_centerY).offset(-5 * WIDTHRADIU);
            make.width.offset(259 * WIDTHRADIU);
            make.height.offset(53 * WIDTHRADIU);
        }];
    }
    return _bottom;
}


/**获取当前window*/
- (UIWindow *)getCurrentWindowView {
    UIWindow * window = [[UIApplication sharedApplication] keyWindow];
    if (window.windowLevel != UIWindowLevelNormal)
    {
        NSArray *windows = [[UIApplication sharedApplication] windows];
        for(UIWindow * tmpWin in windows)
        {
            if (tmpWin.windowLevel == UIWindowLevelNormal)
            {
                window = tmpWin;
                break;
            }
        }
    }
    return window;
}

- (CTShowAdTypeQuest *)adRequest
{
    if (!_adRequest) {
        _adRequest = [[CTShowAdTypeQuest alloc]init];
        //_adRequest.delegate  = self;
    }
    return _adRequest;
}




#pragma mark - 远程通知回调
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
    if (@available(iOS 13.0,*)) {
        NSMutableString *deviceTokenString = [NSMutableString string];
        const char *bytes = deviceToken.bytes;
        NSInteger count = deviceToken.length;
        for (int i = 0; i < count; i++) {
            [deviceTokenString appendFormat:@"%02x", bytes[i]&0x000000FF];
        }
        NSLog(@"deviceToken:%@",deviceTokenString);
      
    }else{
        NSString*deviceTokenString = [[[[deviceToken description]stringByReplacingOccurrencesOfString:@"<"withString:@""]stringByReplacingOccurrencesOfString:@">"withString:@""]stringByReplacingOccurrencesOfString:@" "withString:@""];
        
        NSLog(@"deviceToken:%@",deviceTokenString);
       
    }
    
    //向个推服务器注册deviceToken
    //[GeTuiSdk registerDeviceTokenData:deviceToken];
    
}


#pragma mark - APP运行中接收到通知(推送)处理 - iOS 10以下版本收到推送
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:
(void (^)(UIBackgroundFetchResult))completionHandler {
    [UIApplication sharedApplication].applicationIconBadgeNumber ++;
    // 将收到的APNs信息传给个推统计
    //[GeTuiSdk handleRemoteNotification:userInfo];
//    [self goToMssageViewControllerWith:userInfo];
    completionHandler(UIBackgroundFetchResultNewData);
}

- (void)application:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
}
 
- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context

{
    [_splashView.view removeFromSuperview];
}
-(void)baiduFaceReCo{
//    NSString* licensePath = [[NSBundle mainBundle] pathForResource:FACE_LICENSE_NAME ofType:FACE_LICENSE_SUFFIX];
//    NSAssert([[NSFileManager defaultManager] fileExistsAtPath:licensePath], @"license文件路径不对，请仔细查看文档");
//
//    [[FaceSDKManager sharedInstance] setLicenseID:FACE_LICENSE_ID andLocalLicenceFile:licensePath];
//
//    NSLog(@"baiducanwork=%d",[[FaceSDKManager sharedInstance]canWork]);
//#if TARGET_IPHONE_SIMULATOR
//
//#else
//    NSLog(@"baiduversion=%@", [[FaceVerifier sharedInstance]getVersion]);
//#endif
    
}

#pragma mark - AFNetworking
-(void)dianchi{

    [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
  
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
            case AFNetworkReachabilityStatusReachableViaWWAN:
            case AFNetworkReachabilityStatusReachableViaWiFi:
                self.onLine = YES;
                break;
            case AFNetworkReachabilityStatusNotReachable:
            default:
                self.onLine = NO;
                break;
        }
    }];
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
   
}

//当程序进入后台的时候调用
- (void)applicationWillResignActive:(UIApplication *)application {
//程序准备进入后台通知相关VC 记录当前时间
    NSLog(@"将变为非活跃状态，applicationWillResignActive");
    
//    [LCDManager stopOpenGLESActivity];
}
//当程序进入前台的时候调用
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    NSLog(@"变为活跃状态，applicationDidBecomeActive");
    __weak typeof(self) wself = self;
    if (@available(iOS 14, *)) { 
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
            NSLog(@"app追踪权限：%lu",(unsigned long)status);
                    switch (status) {
                        case ATTrackingManagerAuthorizationStatusDenied:
                            NSLog(@"用户拒绝");
                            break;
                        case ATTrackingManagerAuthorizationStatusAuthorized:
                            NSLog(@"用户允许");
                            [wself initGinsightSDK];
                            break;
                        case ATTrackingManagerAuthorizationStatusNotDetermined:
                            NSLog(@"用户为做选择或未弹窗");
                            break;
                        default:
                            break;
                    }
        }];
     } else {
         if ([ASIdentifierManager.sharedManager isAdvertisingTrackingEnabled]) {
//                 NSString * idfa = [ASIdentifierManager.sharedManager advertisingIdentifier].UUIDString;
                 [wself initGinsightSDK];
           }else {
                 NSLog(@"用户开启了限制广告追踪");
           }
     }
    
}
#pragma mark - 个像初始化
- (void)initGinsightSDK {
//    __weak typeof(self) wself = self;
    [GInsightSDK startSDK:kGcAppId channel:@"appstore" onSuccess:^(NSString *giUid) {
        NSLog(@"个像初始化成功===%@",giUid);
        [UserDefault setValue:giUid forKey:@"giUid"];
        [UserDefault synchronize];
    } onFail:^(NSString *failInfo) {
        NSLog(@"个像初始化失败%@",failInfo);

    }];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
   NSLog(@"进入后台，applicationDidEnterBackground");
    
    self.didEnterBackground = YES;

    self.lastActiveTime = [[NSDate date] timeIntervalSince1970];
}

//程序即将进入前台
- (void)applicationWillEnterForeground:(UIApplication *)application {
    [application setApplicationIconBadgeNumber:0];
    [application cancelAllLocalNotifications];
    
//    BOOL firstLaunch =  [[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"];
//
//    if (self.showSplashWhenBecomeActive && firstLaunch) {
//        NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
//        //指定一个最小展示间隔
//        if (time - self.lastActiveTime >= 60 && self.didEnterBackground) {
//            [self.window addSubview:self.lauchImageView];
//
//        }
//    }
    
}




//- (void)applicationDidBecomeActive:(UIApplication *)application {
//}

- (void)applicationWillTerminate:(UIApplication *)application {
    
    NSLog(@"程序被杀死，applicationWillTerminate");
     [[XMReqMgr sharedInstance]closeXMReqMgr];
}

- (void)application:(UIApplication*)application handleEventsForBackgroundURLSession:(NSString*)identifier completionHandler:(void(^)(void))completionHandler

{

NSLog(@" 应用处于后台，所有下载任务完成调用，handleEventsForBackgroundURLSession");

}

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}
-(void)setAnimation:(UIImageView *)nowView
{
    [UIView animateWithDuration:3.0f delay:0.0f options:UIViewAnimationOptionTransitionFlipFromBottom
                     animations:^
     {
         
         [nowView setFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width , [UIScreen mainScreen].bounds.size.height )];
     }
                     completion:^(BOOL finished)
     {
     }
     ];
}

- (void)confitUShareSettings
{
   
}
- (void)configUSharePlatforms
{
    
     

}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    BOOL result = [[UMSocialManager defaultManager] handleOpenURL:url];
    BOOL result2 = [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
    BOOL result3 = [JANALYTICSService handleUrl:url];
    if (result3) {
        return YES;
    }
    if (result2) {
        return result2;
    }
    if (!result) {
        
    }
    return result;
}

//iOS10以下跳转app
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
    if ([url.absoluteString containsString:@"com.weface.kankanlife://localopen"]) {
        _showAd=YES;
        if ([url.absoluteString containsString:@"com.weface.kankanlife://localopen?"]){
            NSString *prefixUrl = @"com.weface.kankanlife://localopen?";
            NSString *urlType = [url.absoluteString substringFromIndex:prefixUrl.length];
            NSArray *arr = [urlType componentsSeparatedByString:@","];
            if (arr.count == 2) {
                self.OpenpostNotiDic = [NSMutableDictionary dictionary];
                [self.OpenpostNotiDic setValue:arr.firstObject forKey:@"push_type"];
                [self.OpenpostNotiDic setValue:arr.lastObject forKey:@"push_url"];
                
                [self performSelector:@selector(postNoti) withObject:nil afterDelay:1];
            
           }
        }
        
        [self setupUI:YES];
        [self.lauchImageView removeFromSuperview];
        return YES;
    }
//    if([url.absoluteString containsString:@"bxbank"]){
//
//        return YES;
//    }

    BOOL result = [[UMSocialManager defaultManager]  handleOpenURL:url options:options];
    BOOL result2 = [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
    BOOL result3 = [JANALYTICSService handleUrl:url];
    
  
    if (result3) {
        return YES;
    }
    if (result2) {
        return result2;
    }

    if (!result) {
     
    }
    return result;
}
- (void)postNoti{
    if (self.OpenpostNotiDic.count > 0) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"openLinkNoti" object:nil userInfo:self.OpenpostNotiDic];
    }
}
//iOS10以上跳转app
- (void)openURL:(NSURL*)url options:(NSDictionary *)options
completionHandler:(void (^ __nullable)(BOOL success))completion
{
    NSLog(@"url====%@",url.path);
    
    
    BOOL result = [[UMSocialManager defaultManager]  handleOpenURL:url options:options];
    BOOL result2 = [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
    BOOL result3 = [JANALYTICSService handleUrl:url];
    if (result3) {
        completion(result3);
    }
    if (result) {
        completion(result);
    }
    if (result2) {
        completion(result2);
    }
}


/// 通用链接回调方法
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable restorableObjects))restorationHandler {
   
    
    // 通用链
    if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
        NSURL *url = userActivity.webpageURL;
        NSLog(@"通用链接 ：%@", url);
//        NSString *webHost = url.host;
        
        if ([url.absoluteString isEqualToString:@"kksb://h5.weface.com.cn"]){
            
            if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]) {
                UIViewController*lastvc = [Tools jsd_findVisibleViewController];
                if (lastvc) {
//                    LoginVC *loginVC = [[LoginVC alloc]init];
//                    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
//                    [lastvc presentViewController:nav animated:YES completion:nil];
                    
                  
                }
            }else{
                [self aiDaTokenRequest:^(bool success, NSString *token) {
                    [self getBCRequest:token];
                                         
                }];
            }
            
        }
    }else{
        NSURL *webUrl = userActivity.webpageURL;
        // [ GTSDK ]：处理个推APPLink回执统计
        // APPLink url 示例：https://link.gl.ink/getui?n=payload&p=mid， 其中 n=payload 字段存储用户透传信息，可以根据透传内容进行业务操作。
        //NSString *payload = [GeTuiSdk handleApplinkFeedback:webUrl];
//        if (payload) {
//            NSLog(@"[ TestDemo ] 个推APPLink中携带的用户payload信息: %@,URL : %@", payload, webUrl);
//            // TODO: 用户可根据具体 payload 进行业务处理
//        }
    }
    
    if (![[UMSocialManager defaultManager] handleUniversalLink:userActivity options:nil]) {
           // 其他SDK的回调
       }
    
    return YES;
}

//#pragma mark - 点击推送消息跳转
//- (void)handelMessage:(NSDictionary*)msgDic {
//
//    [self goToMssageViewControllerWith:msgDic];
//}


- (void)goToMssageViewControllerWith:(NSDictionary*)msgDic{
    //将字段存入本地，因为要在你要跳转的页面用它来判断,这里我只介绍跳转一个页面，
    NSString * targetStr = [msgDic objectForKey:@"payload"];
    NSDictionary* dic = [self dictionaryWithJsonString:targetStr];
    if ([dic isKindOfClass:[NSDictionary class]]) {
        NSString* push_type = dic[@"push_type"];
        if ([push_type isEqualToString:@"0"]) {
           // UINavigationController* nav = [self currentNC];
            KKNavViewController *nav = (KKNavViewController *)self.window.rootViewController;
            if (nav) {
                NSString* url = dic[@"url"];
                NSString* title = dic[@"title"];
                NewsWebViewController*vc = [NewsWebViewController new];
                vc.title = title;
                vc.url = url;
                vc.hidesBottomBarWhenPushed = YES;
                [nav pushViewController:vc animated:YES];
            }
        }else if ([push_type isEqualToString:@"1"]){
            [self remoteNotificationDictionary:dic];
        }
    }
}


#pragma mark - 原生页面跳转
// 简单封装的页面跳转方法，只是做演示，代码都是没问题的，使用时可以根据业务需求进行修改。
- (void)remoteNotificationDictionary:(NSDictionary *)dict {
    
    UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
    if (rootViewController == nil) {
        NSAssert(0, @"未获取根视图控制器");
        return;
    }
    
    
    // needLogin 可能是 NSNumber 或 NSString，统一按“是否需要登录”解析
    id needLoginObj = dict[@"needLogin"];
    BOOL needLogin = NO;
    if ([needLoginObj isKindOfClass:[NSNumber class]]) {
        needLogin = [(NSNumber *)needLoginObj boolValue];
    } else if ([needLoginObj isKindOfClass:[NSString class]]) {
        NSString *s = [(NSString *)needLoginObj lowercaseString];
        needLogin = ([s isEqualToString:@"1"] || [s isEqualToString:@"yes"] || [s isEqualToString:@"true"]);
    }
    
    [self kkHandelPushNoticationVCWithInfo:dict login:needLogin];
}

- (void)kkHandelPushNoticationVCWithInfo:(NSDictionary *)dict login:(BOOL)login
{
    if (login) {
        if (![[NSUserDefaults standardUserDefaults]boolForKey:@"firstlog"]){
            [UserDefault setBool:NO forKey:@"pushVC"];
            [UserDefault setObject:dict forKey:@"pushInfo"];
            KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
            LoginVC *loginVC = [[LoginVC alloc]init];
            loginVC.block = ^(BOOL show) {
                NSString *className = dict[@"className"];
                NSString *title = dict[@"classTitle"];
                if (className.length > 0) {
                    [[clickEvent instance] clickEventRooterVC:nav1 Content:className menuName:title];
                }
            };
            UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
            [nav1 presentViewController:nav animated:YES completion:nil];
        }else{
            UINavigationController* nav = [self currentNC];
            NSString *className = dict[@"className"];
            NSString *title = dict[@"classTitle"];
            if (className.length > 0) {
                if (nav) {
                    [[clickEvent instance] clickEventRooterVC:nav Content:className menuName:title];
                }
            }
        }
        return;
    }
//    UINavigationController* nav = [self currentNC];
    KKNavViewController *nav = (KKNavViewController *)self.window.rootViewController;
    NSString *className = dict[@"className"];
    NSString *title = dict[@"classTitle"];
    if (className.length > 0) {
        [[clickEvent instance] clickEventRooterVC:nav Content:className menuName:title];
    }
    return;
    //
    // 根据字典字段反射出我们想要的类，并初始化控制器
//    Class class = NSClassFromString(dict[@"className"]);
//    UIViewController *vc = [[class alloc] init];
//    vc.title = dict[@"classTitle"];
//    // 获取参数列表，使用枚举的方式，对控制器属性进行KVC赋值
//    NSDictionary *parameter = dict[@"propertys"];
//    [parameter enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
//        // 在属性赋值时，做容错处理，防止因为后台数据导致的异常
//        if ([vc respondsToSelector:NSSelectorFromString(key)]) {
//            [vc setValue:obj forKey:key];
//        }
//    }];
//    if (nav) {
//        vc.hidesBottomBarWhenPushed = YES;
//        [nav pushViewController:vc animated:YES];
//    }
//    // 从字典中获取方法名，并调用对应的方法
//    NSString* methods = [NSString stringWithFormat:@"%@",dict[@"method"]];
//    if (![Tools isBlankString:methods]) {
//        SEL selector = NSSelectorFromString(methods);
//
//        ((void (*)(id, SEL))[vc methodForSelector:selector])(vc, selector);
//    }
}

#pragma mark - 未登录跳转

- (void)unLoginTap {
    
    UIViewController *rootViewController = self.window.rootViewController;
    
    if (rootViewController == nil) {
        NSAssert(0, @"未获取根视图控制器");
        return;
    }
    
    NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
    
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

        NSString* uid = [UserDefault objectForKey:@"appleId"];
        NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
        NSString* cus_name = [getPeopleID Peopletitle];
        NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
        
        
        BPViewController *bpVC = [[BPViewController alloc]init];
        bpVC.UID = uid;
        bpVC.Id = userId;
        bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
        bpVC.wxPhotoUrl = photoUrl;
        bpVC.title = @"绑定手机号";
        bpVC.from = @"other";
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];

        [rootViewController presentViewController:nav animated:YES completion:nil];
        
        return;

    }
    
    LoginVC *loginVC = [[LoginVC alloc]init];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
    [rootViewController presentViewController:nav animated:YES completion:nil];
}


- (UINavigationController *)currentNC {
    if (![[UIApplication sharedApplication].windows.lastObject isKindOfClass:[UIWindow class]]) {
           NSAssert(0, @"未获取到导航控制器");
           return nil;
       }
       UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
       return [self getCurrentNCFrom:rootViewController];
}


//递归
- (UINavigationController *)getCurrentNCFrom:(UIViewController *)vc
{
    if ([vc isKindOfClass:[UITabBarController class]]) {
        UINavigationController *nc = ((UITabBarController *)vc).selectedViewController;
        return [self getCurrentNCFrom:nc];
    }
    else if ([vc isKindOfClass:[UINavigationController class]]) {
        if (((UINavigationController *)vc).presentedViewController) {
            return [self getCurrentNCFrom:((UINavigationController *)vc).presentedViewController];
        }
        return [self getCurrentNCFrom:((UINavigationController *)vc).topViewController];
    }
    else if ([vc isKindOfClass:[UIViewController class]]) {
        if (vc.presentedViewController) {
            return [self getCurrentNCFrom:vc.presentedViewController];
        }
        else {
            return vc.navigationController;
        }
    }
    else {
        NSAssert(0, @"未获取到导航控制器");
        return nil;
    }
}


#pragma mark - json转字典
- (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString
{
    if (jsonString == nil) {
        return nil;
    }

    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingMutableContainers
                                                          error:&err];
    if(err)
    {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    return dic;

}


#pragma mark - 爱达api请求
- (NSDictionary *)aiDaTokenRequestPara
{
    NSDictionary* params = @{
        @"loginId":[NSNumber numberWithInteger:[getPeopleID PeopleID]].stringValue,
        @"telephone":[getPeopleID PeopleIphoneNmber]
    };
    return params;
}

- (void)aiDaTokenRequest:(void (^)(bool success, NSString*token))response
{
    NSString*url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipAdDaConfig],AiDaTokenRequest];
    NSLog(@"爱达token的url:%@",url);
    
    NSLog(@"params:%@",[self aiDaTokenRequestPara]);
    
    [NetworkRequest Get3:url Params:[self aiDaTokenRequestPara] Success:^(id _Nonnull responseObject) {
        
        NSLog(@"responseObject:%@",responseObject);
        
        if ([responseObject isKindOfClass:[NSDictionary class]]) {
            NSString*state = [NSString stringWithFormat:@"%@",responseObject[@"state"]];
            NSString*describe = [NSString stringWithFormat:@"%@",responseObject[@"describe"]];
            if ([state isEqualToString:@"200"]) {
                
                NSString*token = [NSString stringWithFormat:@"%@",responseObject[@"result"]];
                
                response(YES,token);
                
            }else{
                [SVProgressHUD showErrorWithStatus:describe];
            }
            
        }else{
            [SVProgressHUD showErrorWithStatus:@"服务器异常"];
        }
        
    } Failure:^(NSError * _Nonnull error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD showErrorWithStatus:@"网络异常"];
    }];
}

#pragma mark - 比财

- (NSDictionary *)getBCRequestParam
{
    NSDictionary *params = @{
        @"phone":[[getPeopleID PeopleIphoneNmber] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]],
        @"id":[NSNumber numberWithInteger:[getPeopleID PeopleID]].stringValue
    };
    return params;
}

- (void)getBCRequest:(NSString *)token
{
   NSString*url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipAdDaUrlConfig],BCUrlRequest];
    NSLog(@"比财url的url:%@",url);
    
    NSLog(@"params:%@",[self getBCRequestParam]);
    
    [NetworkRequest Get2:url Params:[self getBCRequestParam] Token:token Success:^(id  _Nonnull responseObject) {
        
         NSLog(@"responseObject:%@",responseObject);
                
        if ([responseObject isKindOfClass:[NSDictionary class]]) {
            NSString*state = [NSString stringWithFormat:@"%@",responseObject[@"state"]];
            NSString*describe = [NSString stringWithFormat:@"%@",responseObject[@"describe"]];
            if ([state isEqualToString:@"200"]) {
                
                NSString*url = [NSString stringWithFormat:@"%@&appBarHide=hide",responseObject[@"result"]];
                
//                NSMutableCharacterSet *lastSet = [[NSMutableCharacterSet alloc] init];
//                   [lastSet formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@"-_.!~*;/?:@&=$,#"]];
//                   [lastSet formUnionWithCharacterSet:[NSCharacterSet letterCharacterSet]];
//                   [lastSet formUnionWithCharacterSet:[NSCharacterSet alphanumericCharacterSet]];
//
//                url = [url stringByAddingPercentEncodingWithAllowedCharacters:lastSet];
                UIViewController*lastvc = [Tools jsd_findVisibleViewController];
                if (lastvc.navigationController) {
                    Web2ViewController * vc = [Web2ViewController new];
                    vc.title= @"存钱罐";
                    vc.skipUrl = [NSURL URLWithString:url];
                    vc.hidesBottomBarWhenPushed = YES;
                    [lastvc.navigationController pushViewController:vc animated:YES];
                }

            }else{
                [SVProgressHUD showErrorWithStatus:describe];
            }
            
        }else{
            [SVProgressHUD showErrorWithStatus:@"服务器异常"];
        }
        
        
    } Failure:^(NSError * _Nonnull error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD showErrorWithStatus:@"网络异常"];
    }];
}


#pragma mark - 听听
- (void)goToListenVC
{
    KKNavViewController *nav = (KKNavViewController *)self.window.rootViewController;
    
    KKLisenViewController*vc = [KKLisenViewController new];
    vc.hidesBottomBarWhenPushed = YES;
    vc.fromHome = YES;
    [nav pushViewController:vc animated:YES];
    return;
}

#pragma mark - 金币中心
- (void)goToCoinCenterVC
{
    
   __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    if (![[NSUserDefaults standardUserDefaults]boolForKey:@"firstlog"]){
        
        NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
        
        if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {
            
            
            
            NSString* uid = [UserDefault objectForKey:@"appleId"];
            NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
            NSString* cus_name = [getPeopleID Peopletitle];
            NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
            
            
            BPViewController *bpVC = [[BPViewController alloc]init];
            bpVC.UID = uid;
            bpVC.Id = userId;
            bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
            bpVC.wxPhotoUrl = photoUrl;
            bpVC.title = @"绑定手机号";
            bpVC.from = @"other";
            UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
            
            
            
            [nav1 presentViewController:nav animated:YES completion:nil];
            
            return;

        }
        
        LoginVC *loginVC = [[LoginVC alloc]init];
        WeakSelf
        loginVC.block = ^(BOOL show) {
            [weakSelf goToCoinCenterVC];
        };
        
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
        [nav1 presentViewController:nav animated:YES completion:nil];
        
        
        return;
    }
    
   
    
    CoinsCenterViewController *vc = [[CoinsCenterViewController alloc]init];
    vc.title = @"打卡赚金币";
    vc.hidesBottomBarWhenPushed = YES;
    vc.Completeblock = ^(BOOL isSuccess) {
        if (isSuccess) {
            nav1.tabBarController.selectedIndex = 2;
        }
    };
    [nav1 pushViewController:vc animated:YES];
}


#pragma mark - 代缴社保
- (void)goToPayShebaoBySelfVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
     
     if (![[NSUserDefaults standardUserDefaults]boolForKey:@"firstlog"]){
         
         NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
         
         if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

             NSString* uid = [UserDefault objectForKey:@"appleId"];
             NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
             NSString* cus_name = [getPeopleID Peopletitle];
             NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
             
             
             BPViewController *bpVC = [[BPViewController alloc]init];
             bpVC.UID = uid;
             bpVC.Id = userId;
             bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
             bpVC.wxPhotoUrl = photoUrl;
             bpVC.title = @"绑定手机号";
             bpVC.from = @"other";
             UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
             
             
             
             [nav1 presentViewController:nav animated:YES completion:nil];
             
             return;

         }
         
         LoginVC *loginVC = [[LoginVC alloc]init];
         WeakSelf
         loginVC.block = ^(BOOL show) {
             [weakSelf goToPayShebaoBySelfVC];
         };
         
         UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
         [nav1 presentViewController:nav animated:YES completion:nil];
         
         
         return;
     }
     
    SSPaymenyViewController *vc = [[SSPaymenyViewController alloc]init];
    vc.title = @"社保缴费";
    vc.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:vc animated:YES];
    return;
}


#pragma mark - 免费果园
- (void)goToFreeFruitVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
//
//     if (![[NSUserDefaults standardUserDefaults]boolForKey:@"firstlog"]){
//
//         NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
//
//         if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {
//
//
//
//             NSString* uid = [UserDefault objectForKey:@"appleId"];
//             NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
//             NSString* cus_name = [getPeopleID Peopletitle];
//             NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
//
//
//             BPViewController *bpVC = [[BPViewController alloc]init];
//             bpVC.UID = uid;
//             bpVC.Id = userId;
//             bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
//             bpVC.wxPhotoUrl = photoUrl;
//             bpVC.title = @"绑定手机号";
//             bpVC.from = @"other";
//             UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
//
//
//
//             [nav1 presentViewController:nav animated:YES completion:nil];
//
//             return;
//
//         }
//
//         LoginVC *loginVC = [[LoginVC alloc]init];
//         WeakSelf
//         loginVC.block = ^(BOOL show) {
//             [weakSelf goToFreeFruitVC];
//         };
//
//         UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
//         [nav1 presentViewController:nav animated:YES completion:nil];
//
//
//         return;
//     }
    
    
    MyFruitViewController *fruitVC = [MyFruitViewController new];
    fruitVC.title = @"免费果园";
    fruitVC.placeId = @"6666";
    fruitVC.buId = @"946405751";
    fruitVC.gdtAdId = @"2062615177198724";
    fruitVC.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:fruitVC animated:YES];
}

#pragma mark - 找工作
- (void)goToFindJobVC
{
    
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
     
     if (![[NSUserDefaults standardUserDefaults]boolForKey:@"firstlog"]){
         
         NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
         
         if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {
             
             
             
             NSString* uid = [UserDefault objectForKey:@"appleId"];
             NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
             NSString* cus_name = [getPeopleID Peopletitle];
             NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
             
             
             BPViewController *bpVC = [[BPViewController alloc]init];
             bpVC.UID = uid;
             bpVC.Id = userId;
             bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
             bpVC.wxPhotoUrl = photoUrl;
             bpVC.title = @"绑定手机号";
             bpVC.from = @"other";
             UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
             
             
             
             [nav1 presentViewController:nav animated:YES completion:nil];
             
             return;

         }
         
         LoginVC *loginVC = [[LoginVC alloc]init];
         WeakSelf
         loginVC.block = ^(BOOL show) {
             [weakSelf goToFindJobVC];
         };
         
         UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
         [nav1 presentViewController:nav animated:YES completion:nil];
         
         
         return;
     }
    
    WebVC *webvc = [[WebVC alloc]init];
    webvc.url = @"https://nginx.weface.com.cn/appH5/workApp/#/home";
    webvc.title = @"找工作";
    webvc.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:webvc animated:YES];
}
#pragma mark - 看视频赚金币/红包
- (void)goToTVVC:(BOOL)fromHome {

    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    KKSVideoViewController *oneVC = [[KKSVideoViewController alloc]initWithType:fromHome];
    oneVC.title = fromHome ?@"看视频" :@"红包视频";
    oneVC.view.backgroundColor = [UIColor whiteColor];
    oneVC.hidesBottomBarWhenPushed = YES;
    
    [nav1 pushViewController:oneVC animated:YES];
    
    
}
#pragma mark - 看新闻
- (void)goToNewsVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    HeadLineViewController*newsVC = [HeadLineViewController new];
    newsVC.title = @"新闻";
    newsVC.from = @"home";
    newsVC.currentIndex = 0;
    newsVC.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:newsVC animated:YES];
}

#pragma mark - 我的钱包
- (void)goToMyWalletVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    MyWalletViewController *vc = [MyWalletViewController new];
    vc.title = @"我的钱包";
    vc.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:vc animated:YES];

}

#pragma mark - 金币排名
- (void)goToCoinRankVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    CoinsRankViewController *coinVC = [CoinsRankViewController new];
    coinVC.title = @"我的金币";
    coinVC.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:coinVC animated:YES];
    
    return;
}

#pragma mark - 收益排行榜
- (void)goToAssetsRankVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    MyRankViewController *vc = [MyRankViewController new];
    vc.title = @"收益排行榜";
    vc.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:vc animated:YES];
    
}

#pragma mark - 金币抽奖
- (void)goToCoinRewardVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    if ([getPeopleID PeopleID] && [getPeopleID PeopleIphoneNmber])
    {
        NSDictionary *params = @{
                                 @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                                 @"telephone": [EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY]
                                 };
        NSString *url =[NSString stringWithFormat:@"%@score/getpersonintegrals",CoinsBaseUrl];
        
//        WeakSelf;
        [BaseNetManager POST2:url parameters:params completionHandler:^(id responseObj, NSError *error) {
            if (responseObj) {
                NSString *code = [responseObj[@"code"] stringValue];
                if ([code isEqualToString:@"0"]) {
                    [getPeopleID getTotalCoins:responseObj[@"result"]];
                    
                    WebVC *webVC = [[WebVC alloc]init];
                     webVC.type = @"home";
                     webVC.title = @"金币抽奖";
                      webVC.url = CoinsRewardedUrl;
                     webVC.hidesBottomBarWhenPushed =YES;
                     [nav1 pushViewController:webVC animated:YES];
                }
            }
        }];
    }
}

#pragma mark - 我的奖品
- (void)goToMyPrizeListVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    MyPrizeListVC *vc = [[MyPrizeListVC alloc]init];
    vc.title = @"我的奖品";
    vc.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:vc animated:YES];
    return;
}

#pragma mark - 邀请好友
- (void)goToInviteFriendsVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    ShareViewController *shareVC = [[ShareViewController alloc]init];
    shareVC.title = @"邀请好友";
    shareVC.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:shareVC animated:YES];
}

#pragma mark - 社保认证跳转
- (void)kkJumpUserIdentifyViewController {
    
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    KKUserIdentifyViewController*vc = [[KKUserIdentifyViewController alloc]init];
    vc.title = @"社保认证";
    vc.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:vc animated:YES];
}

#pragma mark - 补贴认证
- (void)goToBuTieVC
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    DistrictAuthenticationPersonalInfoController* vc = [DistrictAuthenticationPersonalInfoController new];
    vc.title = @"补贴认证";
    vc.type = @"butie";
    vc.hidesBottomBarWhenPushed = YES;
    [nav1 pushViewController:vc animated:YES];
    return;
}

#pragma mark - 医保卡
- (void)goToYiBaoCardVC
{
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"alipays://"]]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"alipays://platformapi/startapp?appId=2021001123625885&page=pages%2findex%2findex%3fprovideId%3d2088331168368991%26chInfo%3dXSbduanfanyong"] options:nil completionHandler:nil];
        return;
        }
    
    if (![WXApi isWXAppInstalled]){
        [Tools showMessage:@"请安装微信APP后重试"];
        return;
    }
    
    WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
    launchMiniProgramReq.userName = @"gh_45334679e384";  //拉起的小程序的username
    launchMiniProgramReq.path = @"pages/nhsa-code/index/index?channel=AAEKTLpkFoE88Zic8BqWR87_&cityCode=440300";    //拉起小程序页面的可带参路径，不填默认拉起小程序首页
    launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
    [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
        
    }];
    return;
}

#pragma mark - 平价药房
- (void)goToYaoDouVCWithLoginUrl:(NSString *)url
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    if ([YDTempUrlInstance shareInstance].data && ![self compareWithLastDate:[YDTempUrlInstance shareInstance].lastDate]) {
        NSURL * skipUrl = [YDAuthenticationHelper jointUrlWithBody:[YDTempUrlInstance shareInstance].data andUrl:url];
        
        Web2ViewController * vc = [Web2ViewController new];
        vc.title= @"平价药房";
        vc.skipUrl = skipUrl;
        [nav1 pushViewController:vc animated:YES];
        [GTCountSDK trackCountEvent:@"H5_PingMingYaoFang" withArgs:nil];
        return;
    }
    
    
    NSDictionary * params = @{@"appId":@"201912161758",
                                 @"phone":[getPeopleID PeopleIphoneNmber]};
       __weak typeof(self) weakSelf = self;
    __block NSString* tempUrl = url;
       [YDAuthenticationHelper authentication:@"https://kankan.yaodouwang.com/user/login/open" body:params success:^(id  _Nonnull response) {
           
           if ([response isKindOfClass:[NSDictionary class]]) {
               NSDictionary * data = response[@"data"];
               NSURL * skipUrl = [YDAuthenticationHelper jointUrlWithBody:data andUrl:tempUrl];
               [YDTempUrlInstance shareInstance].data = data;
               [YDTempUrlInstance shareInstance].lastDate = [NSDate date];
               
               Web2ViewController * vc = [Web2ViewController new];
               vc.title= @"平价药房";
               vc.skipUrl = skipUrl;
               [nav1 pushViewController:vc animated:YES];
               [GTCountSDK trackCountEvent:@"H5_PingMingYaoFang" withArgs:nil];
               
           }else{
               NSLog(@"数据格式不正确 ===> %@",response);
           }
          
       } fail:^(id  _Nonnull error) {
           
           NSLog(@"请求失败，请登录 ===> %@",error);
//           [weakSelf alertShow:@"网络异常,请稍后重试"];
       }];
}

#pragma mark - 提示

- (void)alertShow:(NSString *)msg
{
    __block KKNavViewController *nav1 = (KKNavViewController *)self.window.rootViewController;
    
    if (@available(iOS 9.0,*)) {
        
        UIAlertController * alertV = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        [alertV addAction:confirm];
        
        [nav1 presentViewController:alertV animated:YES completion:nil];
        
    }else{
        UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alertV show];
    }
}


#pragma mark - 二次开屏反射

- (void)goToOtherVCWithDict:(NSDictionary *)dict
{
    // 根据字典字段反射出我们想要的类，并初始化控制器
    Class class = NSClassFromString(dict[@"className"]);
    UIViewController *vc = [[class alloc] init];
    vc.title = dict[@"classTitle"];
    // 获取参数列表，使用枚举的方式，对控制器属性进行KVC赋值
    NSDictionary *parameter = dict[@"propertys"];
    [parameter enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        // 在属性赋值时，做容错处理，防止因为后台数据导致的异常
        if ([vc respondsToSelector:NSSelectorFromString(key)]) {
            [vc setValue:obj forKey:key];
        }
    }];
    
    
    KKNavViewController* nav = (KKNavViewController *)self.window.rootViewController;
    
    if (nav) {
        vc.hidesBottomBarWhenPushed = YES;
        [nav pushViewController:vc animated:YES];
    }
    // 从字典中获取方法名，并调用对应的方法
    NSString* methods = [NSString stringWithFormat:@"%@",dict[@"method"]];
    if (![Tools isBlankString:methods]) {
        SEL selector = NSSelectorFromString(methods);
        
        ((void (*)(id, SEL))[vc methodForSelector:selector])(vc, selector);
    }
}

//跳转微信
-(void)openWechat{
    UIApplication *application = [UIApplication sharedApplication];
    NSURL * url = [NSURL URLWithString:@"weixin://"];
    BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
    //先判断是否能打开该url
    if (canOpen)
    {   //打开微信
//        WeakSelf
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            
            if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
                [application openURL:url options:@{} completionHandler:^(BOOL success) {
                       
                }];
            } else {
                [application openURL:url];
               
            }
            
        });
        
        
    }else {
        [SVProgressHUD showInfoWithStatus:@"您的设备未安装微信APP"];
    }
}



#pragma mark - WXAPIDelegate
/*! @brief 收到一个来自微信的请求，第三方应用程序处理完后调用sendResp向微信发送结果
 *
 * 收到一个来自微信的请求，异步处理完成后必须调用sendResp发送处理结果给微信。
 * 可能收到的请求有GetMessageFromWXReq、ShowMessageFromWXReq等。
 * @param req 具体请求内容，是自动释放的
 */
//- (void)onReq:(BaseReq*)req {
//
//}
///*! @brief 发送一个sendReq后，收到微信的回应
// *
// * 收到一个来自微信的处理结果。调用一次sendReq后会收到onResp。
// * 可能收到的处理结果有SendMessageToWXResp、SendAuthResp等。
// * @param resp具体的回应内容，是自动释放的
// */
//- (void)onResp:(BaseResp*)resp {
//
//    if ([resp isKindOfClass:[WXLaunchMiniProgramResp class]])
//    {
//        NSString *string = resp.errStr;
//        // 对应JsApi navigateBackApplication中的extraData字段数据
//    }
//    if ([resp isKindOfClass:[WXSubscribeMsgResp class]]) {
//        WXSubscribeMsgResp *rep = (WXSubscribeMsgResp *)resp;
//
//    }
//}



/// 通知展示（iOS10及以上版本）
/// @param center center
/// @param notification notification
/// @param completionHandler completionHandler
- (void)GeTuiSdkNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification completionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    NSString *msg = [NSString stringWithFormat:@"[ TestDemo ] [APNs] %@ \n%@", NSStringFromSelector(_cmd), notification.request.content.userInfo];
//    [self.homePage logMsg:msg];
    // [ 参考代码，开发者注意根据实际需求自行修改 ] 根据APP需要，判断是否要提示用户Badge、Sound、Alert等
    //completionHandler(UNNotificationPresentationOptionNone); 若不显示通知，则无法点击通知
    completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
}

/// 收到通知信息
/// @param userInfo apns通知内容
/// @param center UNUserNotificationCenter（iOS10及以上版本）
/// @param response UNNotificationResponse（iOS10及以上版本）
/// @param completionHandler 用来在后台状态下进行操作（iOS10以下版本）
- (void)GeTuiSdkDidReceiveNotification:(NSDictionary *)userInfo notificationCenter:(UNUserNotificationCenter *)center response:(UNNotificationResponse *)response fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    NSString *msg = [NSString stringWithFormat:@"[ TestDemo ] [APNs] %@ \n%@", NSStringFromSelector(_cmd), userInfo];
//    [self.homePage logMsg:msg];
    if(completionHandler) {
        // [ 参考代码，开发者注意根据实际需求自行修改 ] 根据APP需要自行修改参数值
        completionHandler(UIBackgroundFetchResultNoData);
    }
}


/// 收到透传消息
/// @param userInfo    推送消息内容
/// @param fromGetui   YES: 个推通道  NO：苹果apns通道
/// @param offLine     是否是离线消息，YES.是离线消息
/// @param appId       应用的appId
/// @param taskId      推送消息的任务id
/// @param msgId       推送消息的messageid
/// @param completionHandler 用来在后台状态下进行操作（通过苹果apns通道的消息 才有此参数值）
- (void)GeTuiSdkDidReceiveSlience:(NSDictionary *)userInfo fromGetui:(BOOL)fromGetui offLine:(BOOL)offLine appId:(NSString *)appId taskId:(NSString *)taskId msgId:(NSString *)msgId fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    // [ GTSDK ]：汇报个推自定义事件(反馈透传消息)，开发者可以根据项目需要决定是否使用, 非必须
    // [GeTuiSdk sendFeedbackMessage:90001 andTaskId:taskId andMsgId:msgId];
//    NSString *msg = [NSString stringWithFormat:@"[ TestDemo ] [APN] %@ \nReceive Slience: fromGetui:%@ appId:%@ offLine:%@ taskId:%@ msgId:%@ userInfo:%@ ", NSStringFromSelector(_cmd), fromGetui ? @"个推消息" : @"APNs消息", appId, offLine ? @"离线" : @"在线", taskId, msgId, userInfo];
//    [self.homePage logMsg:msg];

    if(completionHandler) {
        // [ 参考代码，开发者注意根据实际需求自行修改 ] 根据APP需要自行修改参数值
        completionHandler(UIBackgroundFetchResultNoData);
    }
}

- (void)GeTuiSdkNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification {
    // [ 参考代码，开发者注意根据实际需求自行修改 ] 根据APP需要自行修改参数值
}


- (void)GeTuiSdkDidOccurError:(NSError *)error {
    NSString *msg = [NSString stringWithFormat:@"[ TestDemo ] [GeTuiSdk GeTuiSdkDidOccurError]:%@\n\n",error.localizedDescription];

    // SDK发生错误时，回调异常错误信息
    NSLog(@"%@", msg);
}

@end

