summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/AppDelegate.m23
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