summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/AppDelegate.m21
-rw-r--r--Juick/Model/Message.h1
-rw-r--r--Juick/Model/Message.m3
3 files changed, 18 insertions, 7 deletions
diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m
index 2592b89..d5d5b9b 100644
--- a/Juick/AppDelegate.m
+++ b/Juick/AppDelegate.m
@@ -66,7 +66,7 @@
registration.token = token;
AFHTTPSessionManager *manager = [APIClient sharedClient].manager;
[manager PUT:@"/notifications" parameters:[@[registration] yy_modelToJSONObject] success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
- NSLog(@"success");
+ NSLog(@"success %@", token);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"fail %@", [error localizedDescription]);
} ];
@@ -98,14 +98,27 @@
UINavigationController *dialogs = (UINavigationController *)[main.viewControllers objectAtIndex:1];
[[dialogs.viewControllers objectAtIndex:0] performSegueWithIdentifier:@"chatSegue" sender:dialogs];
}
- completionHandler();
}];
+ completionHandler();
+}
+
+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
+ if (userInfo[@"service"]) {
+ [[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> * _Nonnull notifications) {
+ for (UNNotification* notification in notifications) {
+ if ([notification.request.content.userInfo[@"mid"] integerValue] == [userInfo[@"mid"] integerValue]) {
+ [[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:@[notification.request.identifier]];
+ }
+ }
+ }];
+ }
+ completionHandler(UIBackgroundFetchResultNewData);
}
-(void) parseNotificationPayload:(NSDictionary *)userInfo {
if (userInfo != nil) {
- self.pushedThread = [userInfo objectForKey:@"mid"];
- self.pushedUname = [userInfo objectForKey:@"uname"];
+ self.pushedThread = userInfo[@"mid"];
+ self.pushedUname = userInfo[@"uname"];
}
}
diff --git a/Juick/Model/Message.h b/Juick/Model/Message.h
index 45b14fa..8e1b01a 100644
--- a/Juick/Model/Message.h
+++ b/Juick/Model/Message.h
@@ -24,5 +24,6 @@
@property NSString *repliesBy;
@property NSNumber *repliesCount;
@property Attachment *attachment;
+@property BOOL service;
@end
diff --git a/Juick/Model/Message.m b/Juick/Model/Message.m
index 2a4090a..d00f705 100644
--- a/Juick/Model/Message.m
+++ b/Juick/Model/Message.m
@@ -13,9 +13,6 @@
+ (NSDictionary *)modelCustomPropertyMapper {
return @{@"text" : @"body",
- @"mid" : @"mid",
- @"rid" : @"rid",
- @"entities": @"entities",
@"attach" : @"photo.small",
@"repliesCount": @"replies",
@"repliesBy": @"repliesby"};