From 8ae952ec8df2a713afeaef5960a88888e050c6fc Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 15 Oct 2017 23:47:11 +0300 Subject: WIP --- Juick/AppDelegate.m | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'Juick/AppDelegate.m') diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index b5c4e27..7be4424 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -20,16 +20,23 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[UINavigationBar appearance] setTintColor:[ColorScheme linkColor]]; + [[UINavigationBar appearance] setBackgroundColor:[ColorScheme headerBackground]]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [ColorScheme linkColor]}]; + [[UIToolbar appearance] setTintColor:[ColorScheme linkColor]]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; return YES; } - --(void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { - [[UIApplication sharedApplication] registerForRemoteNotifications]; +- (void)registerForRemoteNotifications { + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + center.delegate = self; + [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ + if(!error){ + [[UIApplication sharedApplication] registerForRemoteNotifications]; + } + }]; } -(void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { @@ -46,4 +53,16 @@ NSLog(@"Error: %@", [error debugDescription]); } +//Called when a notification is delivered to a foreground app. +-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{ + NSLog(@"User Info : %@",notification.request.content.userInfo); + completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); +} + +//Called to let your app know which action was selected by the user for a given notification. +-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler{ + NSLog(@"User Info : %@",response.notification.request.content.userInfo); + completionHandler(); +} + @end -- cgit v1.2.3