From 47565c3be787fd3e52bff7ce609550d4b835bfad Mon Sep 17 00:00:00 2001 From: Lorenzo Primiterra Date: Wed, 16 Aug 2017 17:06:54 +0300 Subject: [PATCH] Fix on crash when device_token is null --- ooniprobe/AppDelegate.mm | 2 -- ooniprobe/Info.plist | 4 ++-- ooniprobe/Utility/NotificationService.mm | 1 + ooniprobe/Utility/ReachabilityManager.mm | 7 ++++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ooniprobe/AppDelegate.mm b/ooniprobe/AppDelegate.mm index 3631dddcb..fdeb48d8e 100644 --- a/ooniprobe/AppDelegate.mm +++ b/ooniprobe/AppDelegate.mm @@ -20,8 +20,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( CrashlyticsKit.delegate = self; [Fabric with:@[[Crashlytics class]]]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; - - [NotificationService sharedNotificationService]; [self registerNotifications]; diff --git a/ooniprobe/Info.plist b/ooniprobe/Info.plist index 34f23725a..da69b0867 100644 --- a/ooniprobe/Info.plist +++ b/ooniprobe/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1.5 + 1.1.6 CFBundleSignature ???? CFBundleVersion - 14 + 15 Fabric APIKey diff --git a/ooniprobe/Utility/NotificationService.mm b/ooniprobe/Utility/NotificationService.mm index dc97c6a0a..bf293973f 100644 --- a/ooniprobe/Utility/NotificationService.mm +++ b/ooniprobe/Utility/NotificationService.mm @@ -45,6 +45,7 @@ -(id)init - (void)registerNotifications{ + if (device_token == nil) return; std::vector supported_tests_list; for (NSString *s in supported_tests) { diff --git a/ooniprobe/Utility/ReachabilityManager.mm b/ooniprobe/Utility/ReachabilityManager.mm index 77315eb79..a3bbeedbf 100644 --- a/ooniprobe/Utility/ReachabilityManager.mm +++ b/ooniprobe/Utility/ReachabilityManager.mm @@ -43,8 +43,10 @@ - (id)init { - (void)reachabilityDidChange:(NSNotification *)notification { NSString *network_type = [self getStatus]; - [[NotificationService sharedNotificationService] setNetwork_type:network_type]; - [[NotificationService sharedNotificationService] registerNotifications]; + if (![network_type isEqualToString:@"no_internet"]){ + [[NotificationService sharedNotificationService] setNetwork_type:network_type]; + [[NotificationService sharedNotificationService] registerNotifications]; + } } - (NSString*)getStatus{ @@ -56,7 +58,6 @@ - (NSString*)getStatus{ network_type = @"mobile"; else if(status == NotReachable) network_type = @"no_internet"; - NSLog(@"network_type %@", network_type); return network_type; }