Browse Source

ios调试 新通知处理操作

apple 7 năm trước cách đây
mục cha
commit
d369790251

+ 1 - 1
ios/JianYuIOS/JianYuIOS.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/JianYuIOS.xcscheme

@@ -85,7 +85,7 @@
          <EnvironmentVariable
          <EnvironmentVariable
             key = "OS_ACTIVITY_MODE"
             key = "OS_ACTIVITY_MODE"
             value = "disable"
             value = "disable"
-            isEnabled = "YES">
+            isEnabled = "NO">
          </EnvironmentVariable>
          </EnvironmentVariable>
       </EnvironmentVariables>
       </EnvironmentVariables>
       <AdditionalOptions>
       <AdditionalOptions>

BIN
ios/JianYuIOS/JianYuIOS.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate


+ 38 - 0
ios/JianYuIOS/JianYuIOS/AppDelegate.m

@@ -229,6 +229,16 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
             
             
             // 跳转到该链接
             // 跳转到该链接
             [[NSNotificationCenter defaultCenter] postNotificationName:kRequestWebViewWithUrl object:temp userInfo:nil];
             [[NSNotificationCenter defaultCenter] postNotificationName:kRequestWebViewWithUrl object:temp userInfo:nil];
+            
+            
+            if([info[@"type"] isEqualToString:@"message"]) {
+                NSDictionary *dic = @{@"mid":info[@"mid"],
+                                      @"rectype":@"C",
+                                      @"openid":info[@"openid"],
+                                      };
+                [[NSNotificationCenter defaultCenter] postNotificationName:@"messageAccept" object:dic];
+                
+            }
         }
         }
     }
     }
     
     
@@ -237,10 +247,25 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
 
 
 
 
 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
+    NSLog(@"111");
+    NSLog(@"%@",userInfo);
     NSDictionary *info = userInfo[@"info"];
     NSDictionary *info = userInfo[@"info"];
     if ([info isKindOfClass:[NSString class]]) {
     if ([info isKindOfClass:[NSString class]]) {
         info = [[LXViewControllerManager shareViewControllerManager] dictionaryWithJsonString:userInfo[@"info"]];
         info = [[LXViewControllerManager shareViewControllerManager] dictionaryWithJsonString:userInfo[@"info"]];
     }
     }
+    /*
+     {
+     descript = 5555;
+     extend =     {
+     linkType = external;
+     };
+     mid = 5b5bcd5d61fd00478411f0b1;
+     openid = "ocXeA0juxw7b7A_bjXVy0NSJF5f0";
+     title = "\U6d4b\U8bd5\U4e00";
+     url = "https://www.baidu.com";
+     }
+     */
+    NSLog(@"info--新消息%@",info);
     if (info ) {
     if (info ) {
         if (info[@"url"]) {
         if (info[@"url"]) {
             NSString *pushTime = info[@"pushTime"];
             NSString *pushTime = info[@"pushTime"];
@@ -265,6 +290,19 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
             }
             }
             
             
             [[NSNotificationCenter defaultCenter] postNotificationName:kAfterReceiveNewMsg object:nil];
             [[NSNotificationCenter defaultCenter] postNotificationName:kAfterReceiveNewMsg object:nil];
+            
+            
+            
+            if([info[@"type"] isEqualToString:@"message"]) {
+                NSDictionary *dic = @{@"mid":info[@"mid"],
+                                      @"rectype":@"D",
+                                      @"openid":info[@"openid"],
+                                     };
+                [[NSNotificationCenter defaultCenter] postNotificationName:@"messageAccept" object:dic];
+                
+            }
+            
+            
         }
         }
     }
     }
     // Required, iOS 7 Support
     // Required, iOS 7 Support

+ 2 - 1
ios/JianYuIOS/JianYuIOS/BaseClass1/LXDataBaseManager.m

@@ -59,7 +59,7 @@ FMDatabase *db;
     if ([table isEqualToString:kNewsTable]) {
     if ([table isEqualToString:kNewsTable]) {
         NSDictionary *dic = (NSDictionary *)entity;
         NSDictionary *dic = (NSDictionary *)entity;
       BOOL result =  [db executeUpdate:@"INSERT INTO kNewsTable(id, openid, title,content, url, type, readed, comeintime, descript, extend, pushTime) VALUES (?,?,?,?,?,?,?,?,?,?,?)",[LXUserDefaults newsID] ,dic[@"openid"], dic[@"title"],dic[@"content"], dic[@"url"], dic[@"type"], @NO, [LXUserDefaults comeintime], dic[@"descript"], dic[@"extend"], dic[@"pushTime"]];
       BOOL result =  [db executeUpdate:@"INSERT INTO kNewsTable(id, openid, title,content, url, type, readed, comeintime, descript, extend, pushTime) VALUES (?,?,?,?,?,?,?,?,?,?,?)",[LXUserDefaults newsID] ,dic[@"openid"], dic[@"title"],dic[@"content"], dic[@"url"], dic[@"type"], @NO, [LXUserDefaults comeintime], dic[@"descript"], dic[@"extend"], dic[@"pushTime"]];
-        LXLog(@"%d", result);
+        NSLog(@"%d", result);
     }
     }
     
     
     
     
@@ -254,6 +254,7 @@ FMDatabase *db;
             count ++;
             count ++;
         }
         }
     }
     }
+    NSLog(@"count_____%d",count);
     return count;
     return count;
 }
 }
 
 

+ 2 - 2
ios/JianYuIOS/JianYuIOS/BaseClass1/PrefixHeader.pch

@@ -26,8 +26,8 @@
 #define kLoginOut @"kLoginOut"
 #define kLoginOut @"kLoginOut"
 #define kNewsTable @"kNewsTable"
 #define kNewsTable @"kNewsTable"
 
 
-#define kHost @"https://www.jianyu360.com/"
-
+//#define kHost @"https://www.jianyu360.com/"
+#define kHost @"http://webws.qmx.top/"
 //#define kHost @"http://webwcj.qmx.top/"
 //#define kHost @"http://webwcj.qmx.top/"
 //#define kHost @"http://w2blmjy.qmx.top/"
 //#define kHost @"http://w2blmjy.qmx.top/"
 //#define kHost @"123.56.103.12/"
 //#define kHost @"123.56.103.12/"

+ 2 - 2
ios/JianYuIOS/JianYuIOS/Info.plist

@@ -17,7 +17,7 @@
 	<key>CFBundlePackageType</key>
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
 	<key>CFBundleShortVersionString</key>
-	<string>1.0.4</string>
+	<string>1.0.5</string>
 	<key>CFBundleURLTypes</key>
 	<key>CFBundleURLTypes</key>
 	<array>
 	<array>
 		<dict>
 		<dict>
@@ -56,7 +56,7 @@
 		</dict>
 		</dict>
 	</array>
 	</array>
 	<key>CFBundleVersion</key>
 	<key>CFBundleVersion</key>
-	<string>6</string>
+	<string>8</string>
 	<key>LSApplicationQueriesSchemes</key>
 	<key>LSApplicationQueriesSchemes</key>
 	<array>
 	<array>
 		<string>wechat</string>
 		<string>wechat</string>

+ 35 - 4
ios/JianYuIOS/JianYuIOS/ViewController.m

@@ -105,6 +105,10 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
     [[AFNetworkReachabilityManager sharedManager] startMonitoring];
     [[AFNetworkReachabilityManager sharedManager] startMonitoring];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
     
     
+    
+    //2018 7 28修改新增js
+     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(messageAccept:) name:@"messageAccept" object:nil];
+    
 //    [self clearWeb];
 //    [self clearWeb];
 
 
     UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
     UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
@@ -233,20 +237,45 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
         return;
         return;
     }
     }
     NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
     NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
+
     if (urlStr) {
     if (urlStr) {
         [[LXViewControllerManager shareViewControllerManager] showHudText:nil];
         [[LXViewControllerManager shareViewControllerManager] showHudText:nil];
         self.afterOpenPushMessage = YES;
         self.afterOpenPushMessage = YES;
-        NSString *url = [NSString stringWithFormat:@"%@%@", kHost, urlStr];
-        url =  [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
-         [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
+        
+        
+        if([infoDict[@"type"] isEqualToString:@"message"]) {
+            NSString *url = [NSString stringWithFormat:@"%@",urlStr];
+            url =  [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
+            [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
+            [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
+        }else {
+            NSString *url = [NSString stringWithFormat:@"%@%@", kHost, urlStr];
+            url =  [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
+            [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
+            [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
+        }
+        
+        
     }
     }
 
 
     
     
+}
+
+
+-(void)messageAccept:(NSNotification *)userInfo
+{
+    NSDictionary * infoDic = [userInfo object];
+
+    NSString *textJS =  [NSString stringWithFormat:@"messageAccept('%@','%@','%@')",infoDic[@"mid"],infoDic[@"rectype"],infoDic[@"openid"]];
+    JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
+    [context evaluateScript:textJS];
+    
+
 }
 }
 
 
 // 收到通知消息
 // 收到通知消息
 -(void)afterReceiveNewMsg{
 -(void)afterReceiveNewMsg{
+    NSLog(@"afterReceiveNewMsg");
     JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
     JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
     [context evaluateScript:@"afterReceiveNewMsg()"];
     [context evaluateScript:@"afterReceiveNewMsg()"];
 }
 }
@@ -555,6 +584,8 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
 }
 }
 // 取未读消息总数
 // 取未读消息总数
 -(int)jsGetUnReadMessageCount:(NSString *)openid{
 -(int)jsGetUnReadMessageCount:(NSString *)openid{
+    NSLog(@"openid=%@",openid);
+//    NSLog(@"%d",[[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid]);
     return [[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid];
     return [[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid];
 }
 }