Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[connectivity] Fix reachability stream for iOS #2281

Merged
merged 3 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/connectivity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 7 additions & 2 deletions packages/connectivity/ios/Classes/ConnectivityPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ @interface FLTConnectivityPlugin () <FlutterStreamHandler, CLLocationManagerDele

@implementation FLTConnectivityPlugin {
FlutterEventSink _eventSink;
Reachability *_reachabilityForInternetConnection;
}

+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/connectivity/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity
version: 0.4.5+5
version: 0.4.5+6

flutter:
plugin:
Expand Down