|
@@ -32,6 +32,8 @@
|
|
|
#import "KSRCIMDataSource.h"
|
|
|
#import "WXApi.h"
|
|
|
#import "GuideViewController.h"
|
|
|
+#import "HomeworkDetailViewController.h"
|
|
|
+#import "MyCourseViewController.h"
|
|
|
|
|
|
@interface RCNaviDataInfo : NSObject
|
|
|
|
|
@@ -249,7 +251,7 @@
|
|
|
}
|
|
|
[JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
|
|
|
//如不需要使用IDFA,advertisingIdentifier 可为nil
|
|
|
- [JPUSHService setupWithOption:launchOptions appKey:@"7e0282ca92c12c8c45a93bb3"
|
|
|
+ [JPUSHService setupWithOption:launchOptions appKey:@"911d07f359c18a078f29792f"
|
|
|
channel:nil
|
|
|
apsForProduction:JSPUSH_ENVIRONMENT
|
|
|
advertisingIdentifier:nil];
|
|
@@ -332,6 +334,8 @@
|
|
|
当使用"开发/测试环境"的appkey测试推送时,必须用Development的证书打包,并且在后台上传"开发/测试环境"的推送证书,证书必须是development的。
|
|
|
当使用"生产/线上环境"的appkey测试推送时,必须用Distribution的证书打包,并且在后台上传"生产/线上环境"的推送证书,证书必须是distribution的。
|
|
|
*/
|
|
|
+#pragma clang diagnostic push
|
|
|
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
|
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
|
|
|
//注册推送, 用于iOS8以及iOS8之后的系统
|
|
|
UIUserNotificationSettings *settings = [UIUserNotificationSettings
|
|
@@ -344,17 +348,21 @@
|
|
|
UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
|
|
|
[application registerForRemoteNotificationTypes:myTypes];
|
|
|
}
|
|
|
+#pragma clang diagnostic pop
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推送处理2
|
|
|
*/
|
|
|
//注册用户通知设置
|
|
|
+#pragma clang diagnostic push
|
|
|
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
|
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
|
|
|
- (void)application:(UIApplication *)application
|
|
|
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
|
|
|
[application registerForRemoteNotifications];
|
|
|
}
|
|
|
-
|
|
|
+#pragma clang diagnostic pop
|
|
|
/**
|
|
|
* 推送处理3
|
|
|
*/
|
|
@@ -365,25 +373,37 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
[JPUSHService registerDeviceToken:deviceToken];
|
|
|
|
|
|
// 融云
|
|
|
- NSString *token = [self getHexStringForData:deviceToken];
|
|
|
- [[RCIMClient sharedRCIMClient] setDeviceToken:token];
|
|
|
+ [[RCIMClient sharedRCIMClient] setDeviceTokenData:deviceToken];
|
|
|
}
|
|
|
|
|
|
-// Data 转换成 NSString(NSData ——> NSString)
|
|
|
-- (NSString *)getHexStringForData:(NSData *)data {
|
|
|
- NSUInteger len = [data length];
|
|
|
- char *chars = (char *)[data bytes];
|
|
|
- NSMutableString *hexString = [[NSMutableString alloc] init];
|
|
|
- for (NSUInteger i = 0; i < len; i ++) {
|
|
|
- [hexString appendString:[NSString stringWithFormat:@"%0.2hhx", chars[i]]];
|
|
|
+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
|
+ /**
|
|
|
+ * 获取融云推送服务扩展字段2
|
|
|
+ */
|
|
|
+ NSDictionary *pushServiceData = [[RCIMClient sharedRCIMClient] getPushExtraFromRemoteNotification:userInfo];
|
|
|
+ if (pushServiceData) {
|
|
|
+ NSLog(@"该远程推送包含来自融云的推送服务");
|
|
|
+ /**
|
|
|
+ * 统计推送打开率2
|
|
|
+ */
|
|
|
+ [[RCIMClient sharedRCIMClient] recordRemoteNotificationEvent:userInfo];
|
|
|
+
|
|
|
+ for (id key in [pushServiceData allKeys]) {
|
|
|
+ NSLog(@"key = %@, value = %@", key, pushServiceData[key]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ NSLog(@"该远程推送不包含来自融云的推送服务");
|
|
|
+ // 极光推送
|
|
|
+ [JPUSHService handleRemoteNotification:userInfo];
|
|
|
}
|
|
|
- return hexString;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推送处理4
|
|
|
* userInfo内容请参考官网文档
|
|
|
*/
|
|
|
+#pragma clang diagnostic push
|
|
|
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
|
|
|
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
|
|
/**
|
|
|
* 统计推送打开率2
|
|
@@ -404,7 +424,7 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
[JPUSHService handleRemoteNotification:userInfo];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+#pragma clang diagnostic pop
|
|
|
|
|
|
- (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.
|
|
@@ -487,7 +507,21 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
|
|
|
|
|
|
#pragma mark- JPUSHRegisterDelegate
|
|
|
+- (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info {
|
|
|
+ NSLog(@"receive notification authorization status:%lu, info:%@", status, info);
|
|
|
+}
|
|
|
|
|
|
+#ifdef __IPHONE_12_0
|
|
|
+- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification {
|
|
|
+ NSString *title = nil;
|
|
|
+ if (notification) {
|
|
|
+ title = @"从通知界面直接进入应用";
|
|
|
+ }else{
|
|
|
+ title = @"从系统设置界面进入应用";
|
|
|
+ }
|
|
|
+ NSLog(@"%@", title);
|
|
|
+}
|
|
|
+#endif
|
|
|
|
|
|
// iOS 10 Support
|
|
|
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler API_AVAILABLE(ios(10.0)){
|
|
@@ -523,7 +557,42 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
|
|
|
#pragma mark 根据不同消息跳转不同界面
|
|
|
- (void)getVCUserInfoDict:(NSMutableDictionary *)infoDict {
|
|
|
-
|
|
|
+ if (![NSString isEmptyString:[infoDict stringValueForKey:@"memo"]]) {
|
|
|
+ NSData *jsonData = [[infoDict stringValueForKey:@"memo"] mj_JSONData];
|
|
|
+ NSError *error;
|
|
|
+ NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
|
|
|
+ if (!error) {
|
|
|
+ NSString *action = [dict stringValueForKey:@"action"];
|
|
|
+ if ([action isEqualToString:@"app"]) {
|
|
|
+ NSString *pageType = [dict stringValueForKey:@"pageTag"];
|
|
|
+ if ([pageType isEqualToString:@"buyPractice"] || [pageType isEqualToString:@"courseRemind"]) { // 课表
|
|
|
+ [self.tabBarController tabBarSelectedWithIndex:1];
|
|
|
+ CustomNavViewController *navCtrl = self.tabBarController.selectedViewController;
|
|
|
+ [navCtrl popToRootViewControllerAnimated:YES];
|
|
|
+ }
|
|
|
+ else if ([pageType isEqualToString:@"homework"]) {
|
|
|
+ NSString *parmString = [dict stringValueForKey:@"params"];
|
|
|
+ NSData *parmData = [parmString mj_JSONData];
|
|
|
+ NSDictionary *parm = [NSJSONSerialization JSONObjectWithData:parmData options:NSJSONReadingMutableContainers error:&error];
|
|
|
+ if (!error) {
|
|
|
+ HomeworkDetailViewController *detailVC = [[HomeworkDetailViewController alloc] init];
|
|
|
+ detailVC.courseId = [parm stringValueForKey:@"courseId"];
|
|
|
+ CustomNavViewController *navCtrl = self.tabBarController.selectedViewController;
|
|
|
+ [navCtrl pushViewController:detailVC animated:YES];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ NSString *webUrl = [dict stringValueForKey:@"url"];
|
|
|
+ if (![NSString isEmptyString:webUrl]) {
|
|
|
+ KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
|
|
|
+ webCtrl.url = webUrl;
|
|
|
+ CustomNavViewController *navCtrl = self.tabBarController.selectedViewController;
|
|
|
+ [navCtrl pushViewController:webCtrl animated:YES];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (BOOL)isLowerVersionCompareLocalVersion:(NSString *)localVersion serviceVersion:(NSString *)version {
|
|
@@ -571,10 +640,13 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
return;
|
|
|
}
|
|
|
self.messageDict = nil;
|
|
|
+#pragma clang diagnostic push
|
|
|
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
|
MJWeakSelf;
|
|
|
[self.alertView configWithMemo:memo desc:descMessage isForce:isforce callback:^(BOOL isSure) {
|
|
|
weakSelf.isShowMemoAlert = NO;
|
|
|
if (isSure) {
|
|
|
+
|
|
|
if (@available(iOS 10.0, *)) {
|
|
|
if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) {
|
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:openUrl] options:@{} completionHandler:^(BOOL success) {
|
|
@@ -598,10 +670,29 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
|
|
|
}
|
|
|
}];
|
|
|
+#pragma clang diagnostic pop
|
|
|
+
|
|
|
[self.alertView showAlert];
|
|
|
self.isShowMemoAlert = YES;
|
|
|
}
|
|
|
|
|
|
+- (void)requestRongCloudToken {
|
|
|
+ [KSNetworkingManager refreshImTokenRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ NSString *newToken = [dic stringValueForKey:@"data"];
|
|
|
+ if (![NSString isEmptyString:newToken]) {
|
|
|
+ UserDefaultSet(newToken, RongTokenKey);
|
|
|
+ [[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
+ [USER_MANAGER checkTokenEnableConnectRongCloud];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ NSLog(@"error");
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
|
|
|
- (void)initTableBar {
|
|
|
if (self.tabBarController) {
|
|
@@ -679,10 +770,20 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
NSString *action = [dict stringValueForKey:@"action"];
|
|
|
if ([action isEqualToString:@"app"]) {
|
|
|
NSString *pageType = [dict stringValueForKey:@"pageTag"];
|
|
|
- if ([pageType isEqualToString:@""]) {
|
|
|
- NSDictionary *parm = [dict dictionaryValueForKey:@"params"];
|
|
|
- NSLog(@"%@",parm);
|
|
|
+ DISPLAY_INDEX index = DISPLAY_INDEX_FIRST;
|
|
|
+ if ([pageType isEqualToString:@"practiceClass"]) { // 我的课程 ->陪练课
|
|
|
+ index = DISPLAY_INDEX_FIRST;
|
|
|
+ }
|
|
|
+ else if ([pageType isEqualToString:@"liveClass"]) { // 我的课程 ->直播课
|
|
|
+ index = DISPLAY_INDEX_LIVE;
|
|
|
+ }
|
|
|
+ else if ([pageType isEqualToString:@"videoClass"]) { // 我的课程 ->视频课
|
|
|
+ index = DISPLAY_INDEX_VIEO;
|
|
|
}
|
|
|
+ MyCourseViewController *ctrl = [[MyCourseViewController alloc] init];
|
|
|
+ [ctrl displayWithIndex:index];
|
|
|
+ CustomNavViewController *navCtrl = self.tabBarController.selectedViewController;
|
|
|
+ [navCtrl pushViewController:ctrl animated:YES];
|
|
|
}
|
|
|
else { // 空 或者 h5
|
|
|
NSString *webUrl = [dict stringValueForKey:@"url"];
|