Commit 5b43147fdeff0d352bef78e801ca3ff614565457

Authored by zhangxiaowen
1 parent 67bf26e2

中英文推送

CNLiveScioLive.xcodeproj/project.pbxproj
... ... @@ -1499,8 +1499,8 @@
1499 1499 08585DD7215B70DA00FC2CA2 /* JSONKit */ = {
1500 1500 isa = PBXGroup;
1501 1501 children = (
1502   - 08585DD8215B70DA00FC2CA2 /* JSONKit.m */,
1503 1502 08585DD9215B70DA00FC2CA2 /* JSONKit.h */,
  1503 + 08585DD8215B70DA00FC2CA2 /* JSONKit.m */,
1504 1504 );
1505 1505 path = JSONKit;
1506 1506 sourceTree = "<group>";
... ...
CNLiveScioLive/AppDelegate.m
... ... @@ -27,6 +27,14 @@
27 27 // [AvoidCrash makeAllEffective];
28 28 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
29 29 self.window.backgroundColor = [UIColor whiteColor];
  30 +
  31 + //推送
  32 + [self registerRemoteNotification];
  33 + [self registerNotification:launchOptions];
  34 +
  35 + //版本更新
  36 + [self checkAppUpdate];
  37 +
30 38 //收藏
31 39 [[DBAction sharedDBAction] createTable];
32 40  
... ... @@ -37,10 +45,6 @@
37 45  
38 46 //语言
39 47 [self setApplicationLanguage];
40   -
41   - //推送
42   - [self registerRemoteNotification];
43   - [self registerNotification:launchOptions];
44 48  
45 49 [self initializeSDKConfiguration];
46 50  
... ... @@ -65,7 +69,7 @@
65 69 }
66 70  
67 71 [self.window makeKeyAndVisible];
68   -
  72 +
69 73 return YES;
70 74 }
71 75 //语言
... ... @@ -117,7 +121,7 @@
117 121  
118 122 - (void)applicationWillEnterForeground:(UIApplication *)application {
119 123 // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
120   - _isPush = NO;
  124 + self.isPush = NO;
121 125  
122 126 }
123 127  
... ... @@ -125,8 +129,8 @@
125 129 - (void)applicationDidBecomeActive:(UIApplication *)application {
126 130 // 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.
127 131  
128   - if (_isPush) {
129   - if([self.window.rootViewController isKindOfClass:[UITabBarController class]]){
  132 + if (self.isPush) {
  133 + if([self.window.rootViewController isKindOfClass:[XLSlideMenu class]]){
130 134 XLSlideMenu *menu = (XLSlideMenu *)self.window.rootViewController;
131 135 CNLiveTabBarController *tabVC = (CNLiveTabBarController *)menu.rootViewController;
132 136  
... ... @@ -137,17 +141,29 @@
137 141 }else{
138 142 //1选中答记者问或者国新视界
139 143 tabVC.selectedIndex = 0;
140   -
141 144 //2请求跳转
142 145 [self getDataById:_type];
143 146 }
144 147  
  148 + }else if([self.window.rootViewController isKindOfClass:[UITabBarController class]]){
  149 + CNLiveENTabBarController *tabVC = (CNLiveENTabBarController *)self.window.rootViewController;
  150 + //直播
  151 + if([self.type isEqualToString:@"1"]){
  152 + tabVC.selectedIndex = 1;
  153 +
  154 + }else{
  155 + //1选中答记者问或者国新视界
  156 + tabVC.selectedIndex = 0;
  157 +
  158 + //2请求跳转
  159 + [self getDataById:_type];
  160 + }
145 161 }
146 162 }
147 163 }
148 164 - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
149 165 NSLog(@"[XGDemo] register APNS fail.\n[XGDemo] reason : %@", error);
150   - [[NSNotificationCenter defaultCenter] postNotificationName:@"registerDeviceFailed" object:nil];
  166 + [[NSNotificationCenter defaultCenter] postNotificationName:@"RegisterDeviceFailed" object:nil];
151 167 }
152 168  
153 169 -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
... ... @@ -270,11 +286,15 @@
270 286 error:&err];
271 287 NSDictionary *dic = dicData[@"program"];
272 288 if(dic){
273   - if([self.window.rootViewController isKindOfClass:[UITabBarController class]] && self.window.rootViewController.childViewControllers.count > 0){
274   - UINavigationController *nav = self.window.rootViewController.childViewControllers[0];
  289 + XLSlideMenu *menu = (XLSlideMenu *)self.window.rootViewController;
  290 + CNLiveTabBarController *tabVC = (CNLiveTabBarController *)menu.rootViewController;
  291 +
  292 + if([self.window.rootViewController isKindOfClass:[XLSlideMenu class]] && tabVC.childViewControllers.count > 0){
  293 + UINavigationController *nav = tabVC.childViewControllers[0];
275 294  
276 295 //判断推送消息是中文还是英文(初始化sdk配置)
277 296 [self initializeSDKConfigurationByLanguage:YES];
  297 +
278 298 //视频
279 299 if([@"program" isEqualToString:dic[@"type"]]){
280 300 OldVideoDetailViewController *vc = [[OldVideoDetailViewController alloc] initWithDictionary:dic];
... ... @@ -346,7 +366,7 @@
346 366 // App 用户选择通知中的行为
347 367 // App 用户在通知中心清除消息
348 368 // 无论本地推送还是远程推送都会走这个回调
349   -- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
  369 +- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){
350 370  
351 371 //当APP在前台运行时,不做处理
352 372 if( [UIApplication sharedApplication].applicationState == UIApplicationStateActive){
... ... @@ -367,15 +387,23 @@
367 387 NSLog(@"click from Action2");
368 388 }
369 389  
370   - [[XGPush defaultManager] reportXGNotificationResponse:response];
  390 + if (@available(iOS 10.0, *)) {
  391 + [[XGPush defaultManager] reportXGNotificationResponse:response];
  392 + } else {
  393 + // Fallback on earlier versions
  394 + }
371 395  
372 396 completionHandler();
373 397 }
374 398  
375 399 // App 在前台弹通知需要调用这个接口
376   -- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  400 +- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){
377 401 [[XGPush defaultManager] reportXGNotificationInfo:notification.request.content.userInfo];
378   - completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
  402 + if (@available(iOS 10.0, *)) {
  403 + completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
  404 + } else {
  405 + // Fallback on earlier versions
  406 + }
379 407 }
380 408 #endif
381 409 #pragma mark - XGPushDelegate
... ... @@ -397,6 +425,7 @@
397 425 NSLog(@"token:%@",deviceToken);
398 426 NSLog(@"%s, result %@, error %@", __FUNCTION__, error?@"NO":@"OK", error);
399 427 }
  428 +#pragma mark - SDK Configuration
400 429 - (void)initializeSDKConfiguration{
401 430 //注册APP
402 431 [CNLiveStat registerApp:CNLiveAppId appKey:CNLiveAppKey];
... ... @@ -438,5 +467,32 @@
438 467 }
439 468  
440 469 }
  470 +#pragma mark - 版本更新
  471 +- (void)checkAppUpdate{
  472 + NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
  473 + NSString *nowVersion = [infoDict objectForKey:@"CFBundleShortVersionString"];
  474 + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/lookup?id=%@", uAppId]];
  475 + NSString * file = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
  476 + NSDictionary *dic = [file objectFromJSONString];
  477 + NSDictionary *results = [[dic objectForKey:@"results"] firstObject];
  478 + NSString *newVersion =[results objectForKey:@"version"];
  479 + if([newVersion compare:nowVersion options:NSNumericSearch] == NSOrderedDescending) {
  480 + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"upDate"];
  481 + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"版本更新"
  482 + message:[results objectForKey:@"releaseNotes"]
  483 + delegate:self
  484 + cancelButtonTitle:@"取消"
  485 + otherButtonTitles:@"更新",nil];
  486 + [alert show];
  487 + return;
  488 + }
  489 +}
  490 +- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
  491 + if(buttonIndex == 1){
  492 + // 此处加入应用在app store的地址,方便用户去更新,一种实现方式如下:
  493 + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/id%@?ls=1&mt=8", uAppId]];
  494 + [[UIApplication sharedApplication] openURL:url];
  495 + }
  496 +}
441 497  
442 498 @end
... ...
CNLiveScioLive/Pages/Header/PrefixHeader.pch
... ... @@ -78,6 +78,7 @@
78 78 #import "WXApi.h"
79 79 #import "MobClick.h"
80 80 #import "Reachability.h"
  81 +#import "JSONKit.h"
81 82  
82 83 //Category
83 84 #import "UIView+Extension.h"
... ...
CNLiveScioLive/Pages/Home/CNHomeBaseViewController.m
... ... @@ -134,7 +134,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
134 134 }
135 135 else if([model.showType isEqualToString:@"1"]){
136 136 if(model.img && ![model.img isEqualToString:@""]){
137   - return 120;//一张图 左边
  137 + return 80*MainScale+20;//一张图 左边
138 138 }
139 139 return 80;//无图
140 140 }
... ... @@ -144,7 +144,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
144 144 }
145 145 else if([model.showType isEqualToString:@"3"]){
146 146 if(model.img && ![model.img isEqualToString:@""]){
147   - return 120;//一张图 左边
  147 + return 80*MainScale+20;//一张图 左边
148 148 }
149 149 return 80;//无图
150 150  
... ...
CNLiveScioLive/Pages/Home/CNHomeENViewController.m
... ... @@ -142,7 +142,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
142 142 }
143 143 else if([model.showType isEqualToString:@"1"]){
144 144 if(model.img && ![model.img isEqualToString:@""]){
145   - return 120;//一张图 左边
  145 + return 80*MainScale+20;//一张图 左边
146 146 }
147 147 return 80;//无图
148 148 }
... ... @@ -152,7 +152,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
152 152 }
153 153 else if([model.showType isEqualToString:@"3"]){
154 154 if(model.img && ![model.img isEqualToString:@""]){
155   - return 120;//一张图 左边
  155 + return 80*MainScale+20;//一张图 左边
156 156 }
157 157 return 80;//无图
158 158  
... ...
CNLiveScioLive/Pages/Home/外宣要闻/Controller/CNLiveHeraldedNewsViewController.m
... ... @@ -167,7 +167,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
167 167 }
168 168 else if([model.showType isEqualToString:@"1"]){
169 169 if(model.img && ![model.img isEqualToString:@""]){
170   - return 120;//一张图 左边
  170 + return 80*MainScale+20;//一张图 左边
171 171 }
172 172 return 80;//无图
173 173 }
... ... @@ -178,7 +178,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
178 178 }
179 179 else if([model.showType isEqualToString:@"3"]){
180 180 if(model.img && ![model.img isEqualToString:@""]){
181   - return 120;//一张图 左边
  181 + return 80*MainScale+20;//一张图 左边
182 182 }
183 183 return 80;//无图
184 184  
... ... @@ -403,6 +403,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
403 403 _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
404 404 _cycleScrollView.titleLabelTextColor = [UIColor whiteColor];
405 405 _cycleScrollView.titleLabelBackgroundColor = [UIColor clearColor];
  406 + _cycleScrollView.titleLabelTextAlignment = NSTextAlignmentLeft;
406 407 _cycleScrollView.delegate = self;
407 408 }
408 409 return _cycleScrollView;
... ...
CNLiveScioLive/Pages/Home/外宣要闻/View/CNLiveNewsLeftPicTableViewCell.m
... ... @@ -48,7 +48,7 @@
48 48 [self.contentView addSubview:_playImage];
49 49  
50 50 _titleLabel = [[UILabel alloc] init];
51   - _titleLabel.numberOfLines = 0;
  51 + _titleLabel.numberOfLines = 2;
52 52 _titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
53 53 _titleLabel.textColor = HEXCOLOR(0x333333);
54 54 _titleLabel.font = [UIFont systemFontOfSize:16];
... ... @@ -101,9 +101,9 @@
101 101 [_picImage mas_makeConstraints:^(MASConstraintMaker *make) {
102 102 make.left.equalTo(self->_backgroundImage.mas_left).with.offset(5);
103 103 make.top.equalTo(self->_backgroundImage.mas_top).with.offset(5);
104   - make.width.offset(120);
105 104 make.bottom.equalTo(self->_backgroundImage.mas_bottom).with.offset(-5);
106   -
  105 + make.width.offset((self->_backgroundImage.height-10)*16.0/9.0);
  106 +
107 107 }];
108 108  
109 109 [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
... ... @@ -120,7 +120,7 @@
120 120 }];
121 121 if ([_model.type isEqualToString:@"program"]) {
122 122 _playImage.hidden = NO;
123   - _playImage.frame = CGRectMake(10+5+(120-30)/2.0, (self.contentView.height-30)/2.0, 30, 30);
  123 + _playImage.frame = CGRectMake(10+5+((self->_backgroundImage.height-10)*16.0/9.0-30*MainScale)/2.0, (self.contentView.height-30*MainScale)/2.0, 30*MainScale, 30*MainScale);
124 124  
125 125 } else if ([_model.type isEqualToString:@"subject"]) {
126 126 _playImage.hidden = YES;
... ...
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldArticleDetailViewController.m
... ... @@ -120,6 +120,10 @@
120 120 self.navigationItem.title = _dictionary[@"cmsColumnName"];
121 121  
122 122 }
  123 +- (void)viewDidDisappear:(BOOL)animated{
  124 + [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];
  125 +
  126 +}
123 127 - (void)goBack{
124 128 [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];
125 129 [self.navigationController popViewControllerAnimated:YES];
... ...
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldVideoDetailViewController.m
... ... @@ -341,7 +341,10 @@
341 341 video.playUrl = url;
342 342 self.liveController.video = video;
343 343 }
  344 +- (void)viewDidDisappear:(BOOL)animated{
  345 + [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];
344 346  
  347 +}
345 348 - (void)backButtonAction:(UIButton *)sender {
346 349 [(AppDelegate *)[UIApplication sharedApplication].delegate initializeSDKConfiguration];
347 350 [self.navigationController popViewControllerAnimated:YES];
... ...
CNLiveScioLive/Pages/Home/答记者问/Controller/CNLiveReporterAskedViewController.m
... ... @@ -138,7 +138,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
138 138 }
139 139 else if([model.showType isEqualToString:@"1"]){
140 140 if(model.img && ![model.img isEqualToString:@""]){
141   - return 120;//一张图 左边
  141 + return 80*MainScale+20;//一张图 左边
142 142 }
143 143 return 80;//无图
144 144 }
... ... @@ -148,7 +148,7 @@ static NSString *newsUpPicTableViewCell = @&quot;CNLiveNewsUpPicTableViewCell&quot;;
148 148 }
149 149 else if([model.showType isEqualToString:@"3"]){
150 150 if(model.img && ![model.img isEqualToString:@""]){
151   - return 120;//一张图 左边
  151 + return 80*MainScale+20;//一张图 左边
152 152 }
153 153 return 80;//无图
154 154  
... ...
CNLiveScioLive/Pages/My/设置/View/CNLiveSettingTableViewCell.m
... ... @@ -70,13 +70,14 @@ static const NSInteger margin = 10;
70 70  
71 71 }];
72 72  
73   - [_line mas_makeConstraints:^(MASConstraintMaker *make) {
74   - make.left.equalTo(self.contentView.mas_left).with.offset(0);
75   - make.right.equalTo(self.contentView.mas_right).with.offset(0);
76   - make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-0.5);
77   - make.height.offset(0.5);
78   -
79   - }];
  73 +// [_line mas_makeConstraints:^(MASConstraintMaker *make) {
  74 +// make.left.equalTo(self.contentView.mas_left).with.offset(0);
  75 +// make.right.equalTo(self.contentView.mas_right).with.offset(0);
  76 +// make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-0.5);
  77 +// make.height.offset(0.5);
  78 +//
  79 +// }];
  80 + _line.frame = CGRectMake(0, self.contentView.height-0.5, MainScreenWidth, 0.5);
80 81  
81 82 }
82 83  
... ...