You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/08/22 08:00:06 UTC

[GitHub] kornn closed pull request #65: Avoid crashes from conflicts between BPBReachability and CDVReachability

kornn closed pull request #65: Avoid crashes from conflicts between BPBReachability and CDVReachability
URL: https://github.com/apache/cordova-plugin-network-information/pull/65
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/ios/CDVReachability.m b/src/ios/CDVReachability.m
index b43a62d..5132f76 100644
--- a/src/ios/CDVReachability.m
+++ b/src/ios/CDVReachability.m
@@ -97,11 +97,17 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe
 
     // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
     // in case someon uses the Reachability object in a different thread.
-    @autoreleasepool {
-        CDVReachability* noteObject = (__bridge CDVReachability*)info;
-        // Post a notification to notify the client that the network reachability changed.
-        [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
-    }
+    // *** As this would let BPB / FotoappSDK crash, we do not pass on our CDVReachability
+    //    @autoreleasepool {
+    //        CDVReachability* noteObject = (__bridge CDVReachability*)info;
+    //        // Post a notification to notify the client that the network reachability changed.
+    //        [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
+    //    }
+}
+
+- (NetworkStatus)currentBPBReachabilityStatus
+{
+    return [self currentReachabilityStatus];
 }
 
 - (BOOL)startNotifier
@@ -225,13 +231,19 @@ - (BOOL)connectionRequired;
 
 - (NetworkStatus)currentReachabilityStatus
 {
-    NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
-    NetworkStatus retVal = NotReachable;
-    SCNetworkReachabilityFlags flags;
-    if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
-        retVal = [self networkStatusForFlags:flags];
+    @try {
+        NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
+        NetworkStatus retVal = NotReachable;
+        SCNetworkReachabilityFlags flags;
+        if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
+            retVal = [self networkStatusForFlags:flags];
+        }
+        return retVal;
+    }
+    @catch (NSException *exception) {
+        NSLog(@"%@", exception.reason);
+        return 0;
     }
-    return retVal;
 }
 
 @end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org