admin
2023-04-21 0b3a4aaf99ea251bc8e27b96115288f0988fcffe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
//
//  AppDelegate.m
//  BuWanVideo2.0
//
//  Created by weikou on 16/7/28.
//  Copyright © 2016年 com.yeshi.buwansheque.ios. All rights reserved.
//
 
#import "AppDelegate.h"
#import "SlideMenuController.h"
#import "MainViewController.h"
#import "LeftViewController.h"
 
#import "GDTSplashAd.h"
#import "GDTSDKConfig.h"
//#import "GDTTrack.h"
#import "AFNetworkReachabilityManager.h"
 
//#import "XGPush.h"
//#import "XGSetting.h"
 
//#import <AlibcTradeSDK/AlibcTradeSDK.h>
 
#import "RecommendMainController.h"
#import "RecommendController.h"
#import "recommendViewController.h"
#import "subregionViewController.h"
#import "MineViewController.h"
#import "discoverViewController.h"
#import "LeftViewController.h"
#import "SJTabbarViewController.h"
#import "UITabBar+mainTab.h"
#import "GuessLikeViewController.h"
#import "DYDrawVideoController.h"
#import "DYNewsController.h"
#import "DYNovelController.h"
#import "CustomIOSAlertView.h"
 
#import <UMCommon/UMCommon.h>
//#import <UMShare/UMShare.h>
 
#import <BUAdSDK/BUAdSDK.h>
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.h>
 
#import <IQKeyboardManager/IQKeyboardManager.h>
 
//内容联盟
#import <LCDSDK/LCDSDK.h>
 
 
#define LECUsedBundleID   @"com.yeshi.buwanshequ.ios"
 
#define TICK   NSDate *startTime = [NSDate date]
#define TOCK   NSLog(@"Time: %f", -[startTime timeIntervalSinceNow])
 
@interface AppDelegate ()<GDTSplashAdDelegate, BUSplashAdDelegate>
 
@property (strong,nonatomic) GDTSplashAd *splash;
 
@property (nonatomic, strong) BUSplashAd *splashAd;
 
@property (nonatomic, strong) RecommendMainController *vcRecommend;
 
@property (nonatomic, strong) SJTabbarViewController *tabBarController;
 
@property (strong, nonatomic) UIView *bottomView;
@property (nonatomic, strong) UIView *viewBot;
@property bool isFirstIn;
@end
 
@implementation AppDelegate
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    TICK;
    //清空角标
    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
    //设置状态栏的字体颜色
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    _inited=false;
 
    TOCK;
    return YES;
}
 
- (void) initSDK:(BUCompletionHandler)completionHandler{
    [self requestIDFA];
    //集成友盟
    [self setUmeng];
    //[MobClick setLogEnabled:YES];
    
    //集成穿山甲内容联盟
    [self initCSJAd:completionHandler];
    
    //广点通注册
    [GDTSDKConfig registerAppId:GDTADkey];
    
    
    
    [[IQKeyboardManager sharedManager] setEnable:YES];
    [[IQKeyboardManager sharedManager] setEnableAutoToolbar:YES];
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
    [IQKeyboardManager sharedManager].toolbarDoneBarButtonItemText = @"完成";
 
    
    //设置提示框的样式
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setMinimumDismissTimeInterval:3.0];
 
    if(iOS8){
        [self registerPushForIOS8];
    }else{
        [self registerPush];
    }
    
    
}
 
- (void)initData{
   
    if (_inited){
        return;
    }
    _inited=true;
        
   // [self requestIDFA];
    //添加网络监测
    [self NetworkMonitoring];
    
    [self fetchCommenConfig];
    
    [self loadMainView];
}
 
-(void) showPrivacyAndProtocol{
     _isFirstIn = YES;
     self.viewBot = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
     self.viewBot .backgroundColor = [UIColor whiteColor];
     [self.window.rootViewController.view addSubview:self.viewBot];
 
     UIView *viewTop = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 100)];
     [self.viewBot addSubview:viewTop];
    
 
     UIView *views = [[UIView alloc] init];
     views.backgroundColor = [UIColor whiteColor];
     [self.viewBot addSubview:views];
     views.sd_layout.leftEqualToView(self.viewBot).topSpaceToView(viewTop, 0).rightEqualToView(self.viewBot).bottomEqualToView(self.viewBot);
 
     UIImageView *logos = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"375"]];
     [views addSubview:logos];
     logos.sd_layout.centerXEqualToView(views).centerYEqualToView(views).widthIs(KScreenW).heightIs(57);
     float width = [UIScreen mainScreen].bounds.size.width;
     float height = [UIScreen mainScreen].bounds.size.height;
     UIImageView *imageview = [[UIImageView alloc] init];
     
     CGFloat  viewHeight = 0.0;
     if (width == 320.0f && height<=480.0f) {
         // iphone4 iphone4s 上的default图片
         _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"320x480"]];
         //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"320"]];
         viewHeight = 55;
         
     }else if (width ==320.0f && height==568.0f) {
         // iphone5 上的default图片
         _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"320x568"]];
         //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"320"]];
         viewHeight = 55;
         
     } else if (width ==375.0f) {
         // iphone6 上的default图片
         _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"375x667"]];
         //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"375"]];
         viewHeight = 63;
         
     }else{
         // iphone6 plus 上的default图片
         _splash.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414x736"]];
         //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414"]];
         viewHeight = 69;
     }
     if (KIsiPhoneX) {
        // _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"1125x2436"]];
         //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414"]];
     }
     imageview.image = [UIImage imageNamed:@"375"];
     
     UIWindow *keyWindow = self.window;
     CGFloat screenH = [[UIScreen mainScreen] bounds].size.height;
     
     _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, screenH - 100, KScreenW, 100)];
     _bottomView.backgroundColor = [UIColor whiteColor];
 
     imageview.frame = CGRectMake(0, 21.5, _bottomView.frame.size.width, 57);
     [_bottomView addSubview:imageview];
  
     [keyWindow addSubview:self.bottomView];
    
    
    
   
    NSString *content=@"尊敬的影视大全用户:\n       由衷的感谢您选择下载我们的影视大全软件。您的个人信息隐私我们非常尊重并得到保护,我们特别在此申明,并对我们的隐私政策主要的一些信息在此罗列,您需要仔细阅读并理解,只有获得您的“同意”后我们才会合理的获得一些必要的信息。如您有任何疑惑,可通过电子邮箱:ysdq-jubao@qq.com向我方询问,我们团队收到信息后将及时为您解答。\n我们的隐私政策必要信息概要如下:\n";
    content = [content stringByAppendingString:@"一、导言\n"];
    content = [content stringByAppendingString:@"二、关于我们\n"];
    content =[content stringByAppendingString:@"三、本《影视大全隐私政策》适用范围、相关词语涵\n"];
    content =[content stringByAppendingString:@"四、我们如何收集和使用您的个人信息\n"];
    content =[content stringByAppendingString:@"五、我们如何使用Cookie和同类技术\n"];
    content = [content stringByAppendingString:@"六、我们如何共享、转让、公开披露您的个人信息五、您对个人信息享有的控制权六、我们如何存储和保护您的个人信息\n"];
    content = [content stringByAppendingString:@"七、未成年人保护\n"];
    content =[content stringByAppendingString:@"八、本《影视大全隐私政策》的更新\n"];
    content =[content stringByAppendingString:@"九、如何联系我们\n"];
    content =[content stringByAppendingString:@"十、其他\n"];
    content =[content stringByAppendingString:@"如您想了解更多,您可以阅读影视大全"];
 
 
    NSMutableAttributedString   *rootAttrString=[[NSMutableAttributedString alloc] initWithString:@""];
    NSMutableParagraphStyle *pstyle=[[NSMutableParagraphStyle alloc] init];
    //行间距
    pstyle.lineSpacing=5;
    
    NSDictionary *attrDict=@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSParagraphStyleAttributeName:pstyle};
    [rootAttrString insertAttributedString:[[NSAttributedString alloc] initWithString:content attributes:attrDict] atIndex:rootAttrString.length];
    
    
    
    //隐私政策
    attrDict=@{NSLinkAttributeName:[NSURL URLWithString:@"http://h5.ysdq.yeshitv.com/privacy_ios.html"],NSFontAttributeName:[UIFont systemFontOfSize:15]};
    NSAttributedString   *attrString=[[NSAttributedString alloc] initWithString:@"《隐私政策》" attributes:attrDict];
    [rootAttrString insertAttributedString:attrString atIndex:rootAttrString.length];
    
    [rootAttrString insertAttributedString:[[NSAttributedString alloc] initWithString:@"。"] atIndex:rootAttrString.length];
    
    // 弹框
    CustomIOSAlertView *alertView=[[CustomIOSAlertView alloc] init];
    height =  [UIScreen mainScreen].bounds.size.height*2/5;
    width = [UIScreen mainScreen].bounds.size.width*4/5;
    UITextView *textView=[[UITextView alloc] initWithFrame:CGRectMake(0, 50,width ,height)];
    textView.editable=NO;
    textView.font = [UIFont systemFontOfSize:20.0];
    textView.scrollEnabled = YES;
    
    textView.attributedText =rootAttrString;
    
    [alertView setContainerView:textView];
    [alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"不同意",@"同意并继续", nil]];
    [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
        if(buttonIndex ==0){
            //拒绝
            if (@available(iOS 10.0, *)) {
                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:@"影视大全需要您同意后才能提供完整的服务" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [alertView show];
            }
           
        }else{
            [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"privacy_and_protocol"];
            [[NSUserDefaults standardUserDefaults] synchronize];
            //同意
            [alertView close];
            [self next];
        }
    }];
    //
    [alertView show];
}
 
- (void) next{
    [self initSDK:^(BOOL success, NSError *error) {
        
        //加载主页内容
        self.vcRecommend = [[RecommendMainController alloc]init];
        self.vcRecommend.tabBarItem.image = [[UIImage imageNamed:@"nav_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        self.vcRecommend.tabBarItem.selectedImage = [[UIImage imageNamed:@"nav_home_highlight"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UINavigationController *nrecommendVC = [[UINavigationController alloc]initWithRootViewController:self.vcRecommend];
        
        
        subregionViewController *subVC = [[subregionViewController alloc]init];
        subVC.tabBarItem.image = [[UIImage imageNamed:@"Camera-拷贝"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        subVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"Camera"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UINavigationController *nsubVC = [[UINavigationController alloc]initWithRootViewController:subVC];
        
        
        
        LeftViewController *mineVC = [[LeftViewController alloc]init];
        mineVC.tabBarItem.image = [[UIImage imageNamed:@"nav_mine"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        mineVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"nav_mine_highlight"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UINavigationController *nmineVC = [[UINavigationController alloc]initWithRootViewController:mineVC];
        
        
        //信息流
        DYDrawVideoController *drawVC = [[DYDrawVideoController alloc]init];
        drawVC.tabBarItem.image = [[UIImage imageNamed:@"nav_draw_video"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        drawVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"nav_draw_video_highlight"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UINavigationController *ndrawVC = [[UINavigationController alloc]initWithRootViewController:drawVC];
        
        self.tabBarController = [[SJTabbarViewController alloc]init];
        self.tabBarController.viewControllers = @[nrecommendVC,ndrawVC,nmineVC];//nnovelVC
        self.tabBarController.tabBar.tintColor = YTHColor(0, 82, 246);
        self.tabBarController.tabBar.unselectedItemTintColor=YTHColor(153, 153, 153);
        [self.tabBarController.tabBar setClipsToBounds:YES];
        self.tabBarController.tabBar.opaque = YES;
        
        
        NSMutableDictionary *attr3=[NSMutableDictionary dictionary];
        attr3[NSFontAttributeName]=[UIFont systemFontOfSize:10];
        [[UITabBarItem appearance]setTitleTextAttributes:attr3 forState:UIControlStateNormal];
        
        self.window.rootViewController = self.tabBarController;
        //判断用户是否已经获得Uid
        if ([[NSUserDefaults standardUserDefaults] objectForKey:@"uid"]!=nil) {
            //为Uid进行一个赋值,非常重要
            [YTHsharedManger startManger].Uid = [[NSUserDefaults standardUserDefaults] objectForKey:@"uid"];
            //加载主视图
            [self initFinish];
        } else {
            //获取Uid
            [self getUid];
        }
    }];
}
 
- (void) initFinish{
    [self setupBUAdSDK];
}
 
- (void)requestIDFA {
    if (@available(iOS 14, *)) {
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
            
        }];
        
    } else {
        // Fallback on earlier versions
    }
}
 
 
 
- (void)fetchCommenConfig {
    NSMutableDictionary *parms = [[NSMutableDictionary alloc] init];
    [parms setObject:@"getConfig" forKey:@"Method"];
    [[YTHNetInterface startInterface] fetchCommenConfig:parms WithBlock:^(BOOL isSuccessful, id result, NSString *error) {
        if ([result[@"IsPost"] boolValue]) {
            [YTHsharedManger startManger].ad = result[@"Data"][@"adNew"];
            [[NSUserDefaults standardUserDefaults] setObject:result[@"Data"][@"vipLink"]?:@"" forKey:VIPLINK];
            [[NSUserDefaults standardUserDefaults] setObject:result[@"Data"][@"unRegisterLink"]?:@"" forKey:UNREGISTER_LINK];
            [[NSUserDefaults standardUserDefaults] synchronize];
        }else{
            
        }
    }];
}
 
 
- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    if(iOS9){
        //进入后台
        if (self.YBackAppDelegate!=nil) {
            if ([self.YBackAppDelegate respondsToSelector:@selector(OutApplication)]) {
                [self.YBackAppDelegate OutApplication];
            }
        }
    }
    //状态栏重现
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    [LCDManager stopOpenGLESActivity];
    
}
 
- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
 
- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
 
- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    [self initData];
    if(iOS9){
        //进入前台
        if (self.YBackAppDelegate!=nil) {
            if([self.YBackAppDelegate respondsToSelector:@selector(backApplication)]){
                [self.YBackAppDelegate backApplication];
            }
        }
    }
    [LCDManager startOpenGLESActivity];
    
    //状态栏重现
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    //    [GDTTrack activateApp];
}
 
- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
 
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
//    if (![[UMSocialManager defaultManager] handleOpenURL:url]) {
//        BOOL result = [[UMSocialManager defaultManager] handleOpenURL:url];
//        return result;
//    }
    
    return YES;
    
}
 
//IOS9.0 系统新的处理openURL 的API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
    // 新接口写法
//    if (![[UMSocialManager defaultManager] handleOpenURL:url]) {
//        BOOL result = [[UMSocialManager defaultManager] handleOpenURL:url];
//        return result;
//    }
    return YES;
}
 
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
}
 
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
    
}
 
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notifications{
    
}
 
#pragma mark 获取Uid
- (void)getUid{
    [[YTHNetInterface startInterface] getUserWithDevice:[NSString DeviceIdentifier] withSystem:@"1" withblock:^(BOOL isSuccessful, id result, NSString *error) {
        if (isSuccessful) {
            NSDictionary *data = (NSDictionary *)result;
            [YTHsharedManger startManger].Uid =[[data objectForKey:@"Data"] objectForKey:@"Uid"];
            //CommentUrl
            NSLog(@"****************\n %@  \n*************8****",data[@"Data"]);
            NSDictionary *datasourceDic = data[@"Data"];
            NSUserDefaults *uid = [NSUserDefaults standardUserDefaults];
            [uid setValue:datasourceDic[@"Uid"] forKey:@"uid"];
            [uid setValue:datasourceDic[@"ShareUrl"] forKey:@"ShareUrl"];
            [uid setValue:datasourceDic[@"ShareContent"] forKey:@"ShareContent"];
            [uid setValue:datasourceDic[@"CommentUrl"] forKey:@"CommentUrl"];
            [uid setValue:datasourceDic[@"NoticeContent"] forKey:@"NoticeContent"];
            [uid setValue:datasourceDic[@"TuiGuang"] forKey:@"TuiGuang"];
            [uid setValue:datasourceDic[@"IOSDownLoad"] forKey:@"IOSDownLoad"];//0为隐藏  非0为显示
            [uid setValue:datasourceDic[@"ZiXun"] forKey:@"ZiXun"];
            [uid setValue:datasourceDic[@"ShowAd"] forKey:@"ShowAd"];//是否在福利社的地方弹好评的框,1为弹,0为不弹
            [uid synchronize];
            //加载主视图
            [self initFinish];
        }else{
            //判断当前用户是否还保存有Uid,如果没有,要提醒用户暂时不能使用
            if ([YTHsharedManger startManger].Uid == nil) {
                //提醒用户暂不能使用,请检查网络
                //还是允许用户进入
                [self initFinish];
            }
        }
    }];
}
 
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {
//    if ([NSStringFromClass([[[window subviews]lastObject] class]) isEqualToString:@"UITransitionView"]) {
//        return UIInterfaceOrientationMaskAll;
//    }
    return UIInterfaceOrientationMaskPortrait;
}
//穿山甲广告
- (void)setupBUAdSDK {
//    [BUAdSDKManager set :NO];
    // splash AD demo
 
    [self addSplashAD];
}
 
- (void) initCSJAd:(BUCompletionHandler)completionHandler{
    BUAdSDKConfiguration *configuration=[BUAdSDKConfiguration configuration];
    configuration.appID=@"5096047";
    configuration.coppa = @(0);
    configuration.secretKey=@"buwan_ios!@";
    [BUAdSDKManager startWithAsyncCompletionHandler:^(BOOL success, NSError *error) {
        dispatch_async(dispatch_get_main_queue(),^{
            [self initBUContent];
            completionHandler(success,error);
        });
    }];
}
 
//初始化内容联盟
- (void)initBUContent{
    // 初始化LCDSDK
       LCDConfig *config = [LCDConfig new];
   #if DEBUG
       config.logLevel = LCDSDKLogLevelDebug;
   #endif
       // 请使用您的配置文件(例如SDK_Setting_5151488.json)初始化SDK,并确保配置文件已经作为Copy Bundle Resource引入工程
       NSString *configPath = [[NSBundle mainBundle] pathForResource:@"SDK_Setting_5096047" ofType:@"json"];
    
    [LCDManager startWithConfigPath:configPath config:config completion:^(LCDINITStatus initStatus, NSDictionary * _Nonnull userInfo) {
        if (initStatus == LCDINITStatus_success) {
            NSLog(@"初始化注册成功!");
        } else {
            NSLog(@"初始化注册失败,请重新注册");
        }
    }];
    
}
 
#pragma mark - Splash
- (void)addSplashAD {
   CGRect frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width,  [UIScreen mainScreen].bounds.size.height - 100);
 
    self.viewBot = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    self.viewBot .backgroundColor = [UIColor whiteColor];
    [self.window.rootViewController.view addSubview:self.viewBot];
 
    UIView *viewTop = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 100)];
    [self.viewBot addSubview:viewTop];
 
    UIView *views = [[UIView alloc] init];
    views.backgroundColor = [UIColor whiteColor];
    [self.viewBot addSubview:views];
    views.sd_layout.leftEqualToView(self.viewBot).topSpaceToView(viewTop, 0).rightEqualToView(self.viewBot).bottomEqualToView(self.viewBot);
 
    UIImageView *logos = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"375"]];
    [views addSubview:logos];
    logos.sd_layout.centerXEqualToView(views).centerYEqualToView(views).widthIs(KScreenW).heightIs(57);
    
    self.splashAd = [[BUSplashAd alloc] initWithSlotID:@"887379201" adSize:CGSizeMake(frame.size.width, frame.size.height)];
 
    //self.splashAd.tolerateTimeout = 10;
    self.splashAd.delegate = self;
    self.splashAd.tolerateTimeout=3.0;
    float width = [UIScreen mainScreen].bounds.size.width;
    float height = [UIScreen mainScreen].bounds.size.height;
    UIImageView *imageview = [[UIImageView alloc] init];
    
    CGFloat  viewHeight = 0.0;
    if (width == 320.0f && height<=480.0f) {
        // iphone4 iphone4s 上的default图片
        _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"320x480"]];
        //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"320"]];
        viewHeight = 55;
        
    }else if (width ==320.0f && height==568.0f) {
        // iphone5 上的default图片
        _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"320x568"]];
        //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"320"]];
        viewHeight = 55;
        
    } else if (width ==375.0f) {
        // iphone6 上的default图片
        _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"375x667"]];
        //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"375"]];
        viewHeight = 63;
        
    }else{
        // iphone6 plus 上的default图片
        _splash.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414x736"]];
        //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414"]];
        viewHeight = 69;
    }
    if (KIsiPhoneX) {
       // _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"1125x2436"]];
        //imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414"]];
    }
    imageview.image = [UIImage imageNamed:@"375"];
    
    UIWindow *keyWindow = self.window;
    //self.startTime = CACurrentMediaTime();
    [self.splashAd loadAdData];
    //[keyWindow.rootViewController.view addSubview:self.splashAdView];
    
    CGFloat screenH = [[UIScreen mainScreen] bounds].size.height;
    
    //self.splashAdView.frame = CGRectMake(0, 0, KScreenW, screenH - viewHeight);
    
    _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, screenH - 100, KScreenW, 100)];
    _bottomView.backgroundColor = [UIColor whiteColor];
 
    imageview.frame = CGRectMake(0, 21.5, _bottomView.frame.size.width, 57);
    [_bottomView addSubview:imageview];
 
    [keyWindow addSubview:self.bottomView];
    
    //self.splashAd.rootViewController = keyWindow.rootViewController;
}
 
 
- (void)loadAd {
    BOOL res = [GDTSDKConfig registerAppId:GDTADkey];
    if (res) {
        
    }
    self.splash = [[GDTSplashAd alloc] initWithPlacementId:GDTFullADid];
    
    _splash.delegate = self;//设置代理
    
    //根据iPhone设备不同设置不同的背景图
    float width = [UIScreen mainScreen].bounds.size.width;
    float height = [UIScreen mainScreen].bounds.size.height;
    UIImageView *imageview = [[UIImageView alloc]init];
    CGFloat  viewHeight = 0.0;
    if (width == 320.0f && height<=480.0f) {
        // iphone4 iphone4s 上的default图片
        _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"320x480"]];
        imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"320"]];
        viewHeight = 55;
        
    }else if (width ==320.0f && height==568.0f) {
        // iphone5 上的default图片
        _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"320x568"]];
        imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"320"]];
        viewHeight = 55;
        
    }else if (width ==375.0f) {
        // iphone6 上的default图片
        _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"375x667"]];
        imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"375"]];
        viewHeight = 63;
        
    }else{
        // iphone6 plus 上的default图片
        _splash.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414x736"]];
        imageview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"414"]];
        viewHeight = 69;
    }
    if (KIsiPhoneX) {
        _splash.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"1125x2436"]];
    }
    _splash.fetchDelay=5;//开屏拉取的时间,超时则放弃展示
    //    [_splash loadAdAndShowInWindow:self.window];//拉起并展示全屏广告
    
    //    [_splash loadAdAndShowInWindow:self.window withBottomView:[UIView new]];
    _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenH - viewHeight, KScreenW, viewHeight)];
    imageview.frame = CGRectMake(0, 12, _bottomView.frame.size.width, _bottomView.frame.size.height - 6);
    
    [_bottomView addSubview:imageview];
    _bottomView.backgroundColor = [UIColor whiteColor];
    UIView *loadView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, width, viewHeight)];
    loadView.backgroundColor = [UIColor clearColor];
    [_splash loadAdAndShowInWindow:self.window withBottomView:loadView];
    [self.window addSubview:self.bottomView];
}
 
#pragma mark 信鸽推送
- (void)registerPush{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
 
- (void)registerPushForIOS8{
    //Types
    UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
    
    //Actions
    UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init];
    
    acceptAction.identifier = @"ACCEPT_IDENTIFIER";
    acceptAction.title = @"Accept";
    
    acceptAction.activationMode = UIUserNotificationActivationModeForeground;
    acceptAction.destructive = NO;
    acceptAction.authenticationRequired = NO;
    
    //Categories
    UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init];
    
    inviteCategory.identifier = @"INVITE_CATEGORY";
    [inviteCategory setActions:@[acceptAction] forContext:UIUserNotificationActionContextDefault];
    
    [inviteCategory setActions:@[acceptAction] forContext:UIUserNotificationActionContextMinimal];
    
    NSSet *categories = [NSSet setWithObjects:inviteCategory, nil];
    
    UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:categories];
    
    [[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
    
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
 
 
-(void)loadMainView{
 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor=[UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
   
    
    //    tabBarController.tabBar.itemPositioning = UITabBarItemPositioningFill;
    
//    self.window.rootViewController = tabBarController;
    //判断是否已经同意用户协议
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"privacy_and_protocol"]!=nil)
    {
        [self next];
    } else {
        [self showPrivacyAndProtocol];
    }
    
}
 
#pragma mark 友盟集成
- (void)setUmeng{
    
    [UMConfigure initWithAppkey:UmengKey channel:@"App Store"];
    [UMConfigure setLogEnabled:NO];
    
//    //友盟分享
//    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:YMWXKEY appSecret:YMWXSENT  redirectURL:nil];//微信
//    
//    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:YMQQKEY appSecret:YMQQSENT redirectURL:@"http://mobile.umeng.com/social"];//QQ
//
//    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:YMSinaKEY  appSecret:YMSinaSecret redirectURL:@"https://sns.whalecloud.com/sina2/callback"];//新浪
}
 
#pragma mark 阿里百川
//-(void)setAliTrade{
//    // 百川平台基础SDK初始化,加载并初始化各个业务能力插件
//    [[AlibcTradeSDK sharedInstance] asyncInitWithSuccess:^{
//        NSLog(@"成功");
//    } failure:^(NSError *error) {
//        NSLog(@"Init failed: %@", error.description);
//    }];
//
//    // 开发阶段打开日志开关,方便排查错误信息
//    //默认调试模式打开日志,release关闭,可以不调用下面的函数
//    [[AlibcTradeSDK sharedInstance] setDebugLogOpen:YES];
//
//    // 配置全局的淘客参数
//    //如果没有阿里妈妈的淘客账号,setTaokeParams函数需要调用
//    AlibcTradeTaokeParams *taokeParams = [[AlibcTradeTaokeParams alloc] init];
//    taokeParams.pid = nil; //mm_XXXXX为你自己申请的阿里妈妈淘客pid
//    [[AlibcTradeSDK sharedInstance] setTaokeParams:taokeParams];
//
//    //设置全局的app标识,在电商模块里等同于isv_code
//    //没有申请过isv_code的接入方,默认不需要调用该函数
//    //[[AlibcTradeSDK sharedInstance] setISVCode:@"your_isv_code"];
//
//    // 设置全局配置,是否强制使用h5
//    [[AlibcTradeSDK sharedInstance] setIsForceH5:NO];
//}
 
#pragma mark 添加网络监测
- (void)NetworkMonitoring{
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(reachabilityChang:)
                                                 name:AFNetworkingReachabilityDidChangeNotification
                                               object:nil];
}
 
- (void) reachabilityChang: (NSNotification*)note {
    switch ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus) {
        case AFNetworkReachabilityStatusNotReachable:{//无网
            [YTHsharedManger startManger].NetworkStatus = 0;
            [self.bottomView removeFromSuperview];;
            
            if ([self.YNetdelegateRecommend respondsToSelector:@selector(updateNet:)]) {
                [self.YNetdelegateRecommend updateNet:0];
            }
            [self splashDisappear];
        }
            break;
        case AFNetworkReachabilityStatusReachableViaWWAN:{//万维网
            [YTHsharedManger startManger].NetworkStatus = 1;
            if ([self.YNetdelegateRecommend respondsToSelector:@selector(updateNet:)]) {
                [self.YNetdelegateRecommend updateNet:1];
            }
        }
            break;
        case AFNetworkReachabilityStatusReachableViaWiFi:{// 使用WiFi网络
            [YTHsharedManger startManger].NetworkStatus = 2;
            if ([self.YNetdelegateRecommend respondsToSelector:@selector(updateNet:)]) {
                [self.YNetdelegateRecommend updateNet:2];
            }
        }
            break;
        case AFNetworkReachabilityStatusUnknown:{// 当前网络未知
            [YTHsharedManger startManger].NetworkStatus = 3;
            if ([self.YNetdelegateRecommend respondsToSelector:@selector(updateNet:)]) {
                [self.YNetdelegateRecommend updateNet:3];
            }
        }
            break;
    }
    [self fetchCommenConfig];
}
 
//开屏页消失
- (void) splashDisappear{
    //加载首页广告
    if(_vcRecommend!=nil)
    {
        if(_isFirstIn)
        {
            [_vcRecommend loadDataFromFile];
        }
        [_vcRecommend loadFullscreenVideoAd];
    }
}
 
#pragma mark BUSplashAdDelegate
//- (void)splashAdDidLoad:(BUSplashAdView *)splashAd {
//    if (splashAd.zoomOutView) {
//        UIViewController *parentVC = [UIApplication sharedApplication].keyWindow.rootViewController;
//        [parentVC.view addSubview:splashAd.zoomOutView];
//        [parentVC.view bringSubviewToFront:splashAd];
//        //Add this view to your container
//        [parentVC.view insertSubview:splashAd.zoomOutView belowSubview:splashAd];
//        splashAd.zoomOutView.rootViewController = parentVC;
//    }
//}
 
///新版本回调
///
- (void)splashAdLoadFail:(BUSplashAd *)splashAd error:(BUAdError *)error{
    [self.viewBot removeFromSuperview];
   // [splashAd removeFromSuperview];
    [self.bottomView removeFromSuperview];
    self.bottomView = nil;
    [self loadAd];
    [self pbu_logWithSEL:_cmd msg:@""];
}
- (void)splashAdLoadSuccess:(BUSplashAd *)splashAd{
    NSLog(@"splashAdLoadSuccess");
    [splashAd showSplashViewInRootViewController:self.window.rootViewController];
}
 
- (void)splashAdRenderSuccess:(BUSplashAd *)splashAd{
    [self pbu_logWithSEL:_cmd msg:@""];
}
 
- (void)splashAdDidClose:(nonnull BUSplashAd *)splashAd closeType:(BUSplashAdCloseType)closeType {
    [self.viewBot removeFromSuperview];
    //[splashAd removeFromSuperview];
    [self.bottomView removeFromSuperview];
    [self pbu_logWithSEL:_cmd msg:@""];
    [self splashDisappear];
}
 
 
- (void)splashAdDidShow:(nonnull BUSplashAd *)splashAd {
    [self pbu_logWithSEL:_cmd msg:@""];
}
 
 
- (void)splashAdViewControllerDidClose:(nonnull BUSplashAd *)splashAd {
    [self pbu_logWithSEL:_cmd msg:@""];
}
 
 
- (void)splashAdWillShow:(nonnull BUSplashAd *)splashAd {
    [self pbu_logWithSEL:_cmd msg:@""];
}
 
 
- (void)splashDidCloseOtherController:(nonnull BUSplashAd *)splashAd interactionType:(BUInteractionType)interactionType {
    [self pbu_logWithSEL:_cmd msg:@""];
}
 
 
- (void)splashVideoAdDidPlayFinish:(nonnull BUSplashAd *)splashAd didFailWithError:(nonnull NSError *)error {
    [self pbu_logWithSEL:_cmd msg:@""];
}
 
 
- (void)pbu_logWithSEL:(SEL)sel msg:(NSString *)msg {
    
}
 
 
#pragma mark -GDTSplashAdDelegate
-(void)splashAdSuccessPresentScreen:(GDTSplashAd *)splashAd
{
    NSLog(@"%s",__FUNCTION__);
}
 
-(void)splashAdFailToPresent:(GDTSplashAd *)splashAd withError:(NSError *)error
{
    self.bottomView.hidden = YES;
    [self.bottomView removeFromSuperview];
    NSLog(@"%s%@",__FUNCTION__,error);
    [self splashDisappear];
}
 
-(void)splashAdClicked:(GDTSplashAd *)splashAd
{
    self.bottomView.hidden = YES;
    [self.bottomView removeFromSuperview];
    NSLog(@"%s",__FUNCTION__);
}
 
-(void)splashAdApplicationWillEnterBackground:(GDTSplashAd *)splashAd
{
    NSLog(@"%s",__FUNCTION__);
}
 
-(void)splashAdWillClosed:(GDTSplashAd *)splashAd
{
    self.bottomView.hidden = YES;
    [self.bottomView removeFromSuperview];
    NSLog(@"%s",__FUNCTION__);
}
 
-(void)splashAdClosed:(GDTSplashAd *)splashAd
{
    NSLog(@"splash-ad gdt close");
    NSLog(@"%s",__FUNCTION__);
    self.bottomView.hidden = YES;
    [self.bottomView removeFromSuperview];
    _splash = nil;
    [self splashDisappear];
}
 
- (void)splashAdWillPresentFullScreenModal:(GDTSplashAd *)splashAd
{
    NSLog(@"%s",__FUNCTION__);
}
 
- (void)splashAdDidPresentFullScreenModal:(GDTSplashAd *)splashAd
{
    NSLog(@"%s",__FUNCTION__);
}
 
- (void)splashAdWillDismissFullScreenModal:(GDTSplashAd *)splashAd
{
    self.bottomView.hidden = YES;
    [self.bottomView removeFromSuperview];
    
    NSLog(@"%s",__FUNCTION__);
    
}
-(void)splashAdDidDismissFullScreenModal:(GDTSplashAd *)splashAd
{
    
    NSLog(@"%s",__FUNCTION__);
}
 
 
@end