diff --git a/packages/connectivity/CHANGELOG.md b/packages/connectivity/CHANGELOG.md index 17e49e25cbd8..0e1ea814907a 100644 --- a/packages/connectivity/CHANGELOG.md +++ b/packages/connectivity/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.5+6 + +* Fix singleton Reachability problem on iOS. + ## 0.4.5+5 * Add an analyzer check for the public documentation. diff --git a/packages/connectivity/ios/Classes/ConnectivityPlugin.m b/packages/connectivity/ios/Classes/ConnectivityPlugin.m index c69871175b01..100e70b44ec6 100644 --- a/packages/connectivity/ios/Classes/ConnectivityPlugin.m +++ b/packages/connectivity/ios/Classes/ConnectivityPlugin.m @@ -22,6 +22,7 @@ @interface FLTConnectivityPlugin () *)registrar { @@ -174,12 +175,16 @@ - (FlutterError*)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink selector:@selector(onReachabilityDidChange:) name:kReachabilityChangedNotification object:nil]; - [[Reachability reachabilityForInternetConnection] startNotifier]; + _reachabilityForInternetConnection = [Reachability reachabilityForInternetConnection]; + [_reachabilityForInternetConnection startNotifier]; return nil; } - (FlutterError*)onCancelWithArguments:(id)arguments { - [[Reachability reachabilityForInternetConnection] stopNotifier]; + if (_reachabilityForInternetConnection) { + [_reachabilityForInternetConnection stopNotifier]; + _reachabilityForInternetConnection = nil; + } [[NSNotificationCenter defaultCenter] removeObserver:self]; _eventSink = nil; return nil; diff --git a/packages/connectivity/pubspec.yaml b/packages/connectivity/pubspec.yaml index c68109d835da..8dce3c8867b6 100644 --- a/packages/connectivity/pubspec.yaml +++ b/packages/connectivity/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for discovering the state of the network (WiFi & mobile/cellular) connectivity on Android and iOS. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity -version: 0.4.5+5 +version: 0.4.5+6 flutter: plugin: