Browse Source

推送区分极光和普通

Steven 9 months ago
parent
commit
a7ed4c9841
1 changed files with 14 additions and 11 deletions
  1. 14 11
      KulexiuForStudent/KulexiuForStudent/AppDelegate.m

+ 14 - 11
KulexiuForStudent/KulexiuForStudent/AppDelegate.m

@@ -522,18 +522,21 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
 
 #pragma mark 根据不同消息跳转不同界面
 - (void)getVCUserInfoDict:(NSMutableDictionary *)infoDict {
-    if (![NSString isEmptyString:[infoDict ks_stringValueForKey:@"memo"]]) {
-        NSData *jsonData = [[infoDict ks_stringValueForKey:@"memo"] mj_JSONData];
-        NSError *error;
-        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
-        if (!error) {
-            UIViewController *vc = self.window.rootViewController;
-            NSString *token = UserDefault(TokenKey);
-            if ([vc isKindOfClass:[LaunchAnimationViewController class]] || [NSString isEmptyString:token]) {
-                self.outLinkParm = [NSMutableDictionary dictionaryWithDictionary:dict];
-                return;
+    BOOL isJPush = [[infoDict allKeys] containsObject:@"_j_msgid"]; // 极光推送标识区分
+    if (isJPush) {
+        if (![NSString isEmptyString:[infoDict ks_stringValueForKey:@"memo"]]) {
+            NSData *jsonData = [[infoDict ks_stringValueForKey:@"memo"] mj_JSONData];
+            NSError *error;
+            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
+            if (!error) {
+                UIViewController *vc = self.window.rootViewController;
+                NSString *token = UserDefault(TokenKey);
+                if ([vc isKindOfClass:[LaunchAnimationViewController class]] || [NSString isEmptyString:token]) {
+                    self.outLinkParm = [NSMutableDictionary dictionaryWithDictionary:dict];
+                    return;
+                }
+                [self handSource:dict];
             }
-            [self handSource:dict];
         }
     }
     else {