diff options
author | Vitaly Takmazov | 2018-12-19 20:16:48 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-12-19 20:16:48 +0300 |
commit | a7bb03e153785b6eead8031b648c23256bb63933 (patch) | |
tree | 0eec47654d12fbd6a55a797f7ceca3563f94df12 /Juick | |
parent | aae765d699995ecfb1f56b902b047a56093fb34d (diff) |
Do not check for first run when remote notification is available
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/AppDelegate.m | 23 |
1 files changed, 12 insertions, 11 deletions
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 |