|
21 | 21 | #import "AppDelegate.h" |
22 | 22 | #import "WebViewController.h" |
23 | 23 |
|
| 24 | +#import "UnReadManager.h" |
| 25 | + |
24 | 26 | @interface BaseViewController () |
25 | 27 |
|
26 | 28 | @end |
@@ -84,24 +86,44 @@ - (void)forceChangeToOrientation:(UIInterfaceOrientation)interfaceOrientation{ |
84 | 86 | } |
85 | 87 |
|
86 | 88 | #pragma mark Notification |
87 | | -+ (void)handleNotificationInfo:(NSDictionary *)userInfo{ |
88 | | - //标记为已读 |
89 | | - NSString *notification_id = [userInfo objectForKey:@"notification_id"]; |
90 | | - if (notification_id) { |
91 | | - [[Coding_NetAPIManager sharedManager] request_markReadWithCodingTip:notification_id andBlock:^(id data, NSError *error) { |
92 | | - if (error) { |
93 | | - NSLog(@"request_markReadWithCodingTip: %@", error.description); |
94 | | - }else{ |
95 | | - NSLog(@"request_markReadWithCodingTip: %@", data); |
| 89 | ++ (void)handleNotificationInfo:(NSDictionary *)userInfo applicationState:(UIApplicationState)applicationState{ |
| 90 | + |
| 91 | + |
| 92 | + if (applicationState == UIApplicationStateInactive) { |
| 93 | + //If the application state was inactive, this means the user pressed an action button from a notification. |
| 94 | + //标记为已读 |
| 95 | + NSString *notification_id = [userInfo objectForKey:@"notification_id"]; |
| 96 | + if (notification_id) { |
| 97 | + [[Coding_NetAPIManager sharedManager] request_markReadWithCodingTip:notification_id andBlock:^(id data, NSError *error) { |
| 98 | + if (error) { |
| 99 | + NSLog(@"request_markReadWithCodingTip: %@", error.description); |
| 100 | + }else{ |
| 101 | + NSLog(@"request_markReadWithCodingTip: %@", data); |
| 102 | + } |
| 103 | + }]; |
| 104 | + } |
| 105 | + //弹出临时会话 |
| 106 | + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
| 107 | + NSLog(@"handleNotificationInfo : %@", userInfo); |
| 108 | + NSString *param_url = [userInfo objectForKey:@"param_url"]; |
| 109 | + [self presentLinkStr:param_url]; |
| 110 | + }); |
| 111 | + }else if (applicationState == UIApplicationStateActive){ |
| 112 | + //处理私信 |
| 113 | + NSString *param_url = [userInfo objectForKey:@"param_url"]; |
| 114 | + NSString *conversionRegexStr = @"/user/messages/history/([^/]+)$"; |
| 115 | + NSArray *matchedCaptures = [param_url captureComponentsMatchedByRegex:conversionRegexStr]; |
| 116 | + if (matchedCaptures.count >0 && [[BaseViewController presentingVC] isKindOfClass:[ConversationViewController class]]) { |
| 117 | + NSString *user_global_key = [matchedCaptures lastObject]; |
| 118 | + ConversationViewController *vc = (ConversationViewController *)[BaseViewController presentingVC]; |
| 119 | + if ([vc.myPriMsgs.curFriend.global_key isEqualToString:user_global_key]) { |
| 120 | + [vc refreshLoadMore:NO]; |
| 121 | + return; |
96 | 122 | } |
97 | | - }]; |
| 123 | + } |
| 124 | + //标记未读 |
| 125 | + [[UnReadManager shareManager] updateUnRead]; |
98 | 126 | } |
99 | | - //弹出临时会话 |
100 | | - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
101 | | - NSLog(@"handleNotificationInfo : %@", userInfo); |
102 | | - NSString *param_url = [userInfo objectForKey:@"param_url"]; |
103 | | - [self presentLinkStr:param_url]; |
104 | | - }); |
105 | 127 | } |
106 | 128 | + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr{ |
107 | 129 | NSLog(@"\n analyseVCFromLinkStr : %@", linkStr); |
|
0 commit comments