diff options
Diffstat (limited to 'Juick/AppDelegate.m')
-rw-r--r-- | Juick/AppDelegate.m | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index bfde8cf..aac90c7 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -16,8 +16,6 @@ #import "FeedViewController.h" #import "NSData+Hex.h" -NSString * const UserUpdatedNotificationName = @"UserUpdated"; - @interface AppDelegate() -(void) parseNotificationPayload:(NSDictionary *)userInfo; @end @@ -119,24 +117,17 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated"; if (userInfo[@"service"]) { User *user = [User fromJSON:userInfo[@"user"]]; application.applicationIconBadgeNumber = user.unreadCount; - UITabBarController *main = (UITabBarController *)[self navigator]; - UIViewController *discussions = [main.viewControllers objectAtIndex:1]; - if (user.unreadCount > 0) { - [discussions tabBarItem].badgeColor = [UIColor colorNamed:@"Funny"]; - [discussions tabBarItem].badgeValue = [NSString stringWithFormat:@"%ld", user.unreadCount]; - } else { - [discussions tabBarItem].badgeValue = nil; - } - [[NSNotificationCenter defaultCenter] postNotificationName:UserUpdatedNotificationName object:user]; [[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); }]; + } else { + completionHandler(UIBackgroundFetchResultNoData); } - completionHandler(UIBackgroundFetchResultNewData); } -(void) parseNotificationPayload:(NSDictionary *)userInfo { |