From a7bb03e153785b6eead8031b648c23256bb63933 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 19 Dec 2018 20:16:48 +0300 Subject: Do not check for first run when remote notification is available --- Juick/AppDelegate.m | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'Juick/AppDelegate.m') diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index 629c6ca..a07d0e3 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -33,15 +33,18 @@ [[UITabBar appearance] setTintColor:[ColorScheme linkColor]]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; - if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FirstRun"] == nil) { - [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.username"]; - [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.password"]; - [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"FirstRun"]; - } [self registerForRemoteNotifications]; NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; - [self parseNotificationPayload:userInfo]; + if (userInfo) { + [self parseNotificationPayload:userInfo]; + } else { + if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FirstRun"] == nil) { + [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.username"]; + [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.password"]; + [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"FirstRun"]; + } + } return YES; } @@ -49,7 +52,7 @@ UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ - if(!error){ + if (!error) { [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [[UIApplication sharedApplication] registerForRemoteNotifications]; }]; @@ -117,10 +120,8 @@ } -(void) parseNotificationPayload:(NSDictionary *)userInfo { - if (userInfo != nil) { - self.pushedThread = userInfo[@"mid"]; - self.pushedUname = userInfo[@"uname"]; - } + self.pushedThread = userInfo[@"mid"]; + self.pushedUname = userInfo[@"uname"]; } @end -- cgit v1.2.3