diff options
Diffstat (limited to 'src/objective-c/GRPCClient/private')
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h | 4 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h index be58138c78..e341b6ef6c 100644 --- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h +++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.h @@ -72,6 +72,6 @@ * Only one handler is active at a time, so if this method is called again before the previous * handler has been called, it might never be called at all (or yes, if it has already been queued). */ -- (void)handleLossWithHandler:(void (^)())lossHandler - wifiStatusChangeHandler:(void (^)())wifiStatusChangeHandler; +- (void)handleLossWithHandler:(nullable void (^)())lossHandler + wifiStatusChangeHandler:(nullable void (^)())wifiStatusChangeHandler; @end diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m index c6f6b39b61..40afca2d3d 100644 --- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m +++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m @@ -151,15 +151,16 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target, return returnValue; } -- (void)handleLossWithHandler:(void (^)())lossHandler - wifiStatusChangeHandler:(void (^)())wifiStatusChangeHandler { +- (void)handleLossWithHandler:(nullable void (^)())lossHandler + wifiStatusChangeHandler:(nullable void (^)())wifiStatusChangeHandler { __weak typeof(self) weakSelf = self; [self startListeningWithHandler:^(GRPCReachabilityFlags *flags) { typeof(self) strongSelf = weakSelf; if (strongSelf) { - if (!flags.reachable) { + if (lossHandler && !flags.reachable) { lossHandler(); - } else if (strongSelf->_previousReachabilityFlags && + } else if (wifiStatusChangeHandler && + strongSelf->_previousReachabilityFlags && (flags.isWWAN ^ strongSelf->_previousReachabilityFlags.isWWAN)) { wifiStatusChangeHandler(); |