diff options
author | Vitaly Takmazov | 2017-10-15 23:47:11 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-15 23:47:11 +0300 |
commit | 8ae952ec8df2a713afeaef5960a88888e050c6fc (patch) | |
tree | b7b09deed573336e5d274eed790c30ba57e4a910 /Juick/AppDelegate.m | |
parent | 6499148cb3f62e20534b62c181125ebeacfa3438 (diff) |
WIP
Diffstat (limited to 'Juick/AppDelegate.m')
-rw-r--r-- | Juick/AppDelegate.m | 25 |
1 files changed, 22 insertions, 3 deletions
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 |