plus_plugins
plus_plugins copied to clipboard
checkConnectivity always return none on iOS 15.4
System info
Platform the Issue occurs on: iOS 15.4 (Simulator)
Plugin name: connectivity_plus
Plugin version: ^2.3.0
Steps to Reproduce
- call
await (Connectivity().checkConnectivity())
- check the result which is always
ConnectivityResult.none
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.none) {
print('no internet'); // the result is always none
}
Flutter doctor output
[✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-x64, locale en-US)
• Flutter version 2.10.5 at /Users/beitari/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (2 weeks ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/beitari/Library/Android/sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.2.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.66.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.40.0
[✓] Connected device (2 available)
• iPhone 13 (mobile) • 4015B4E1-4D93-4D88-B798-C612A12CCE1D • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.127
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
getting the same issue, please have you gotten any fix ?
same issue, new version of simulator respond none to checkConnectivity()
method.
I think plugin must change in iOS side.
any update?
I'm seeing it on iOS 15.5 (physical device).
Simulator 15.4 and real iPhone 15.1 return 'none' sometimes, not every time. Very frustrating.
I have the same issue. I am using connectivity_plus: ^2.3.5
using iOS simulator 15.5
after stopping the internet connection and I reconnect again, it will always return ConnectivityResult.none
in some condition ( unfortunately I can't reproduce it)
this issue persist.
Having the same issue......
Any news? This issue prevents us from using the plugin in production.
when listing for "onConnectivityChanged", it gives following 2 result, even though we are connected to WIFI
ConnectivityResult.none ConnectivityResult.wifi
This triggers when we start the app ( even though we didnt change the connectivity ). But when I checked the old plugin ( connectivity: ^3.0.6 ), the "onConnectivityChanged" is not trigger when the app started and it only triggers when we switch the connectivity
When the wifi and mobile data are OFF, and then mobile data is turned ON the onConnectivityChanged will be called multiple times.
It seems that it is called before there is an actual mobile connection since I try to ping a server every time when the onConnectivityChanged is called to check for a real internet connection, and it throws an error.
A really ugly workaround is to debaunce onConnectivityChanged for 1 second, to avoid those quick false changes.
final Debouncer _debouncer = Debouncer(milliseconds: 1000);
_networkConnectivity.onConnectivityChanged.listen((ConnectivityResult result) {
// Workaround when turning on mobile data
// The listener will be called before the mobile data is enabled
// and returning invalid result
_debouncer.run(() => checkStatus());
});
Future<bool> checkStatus() async {
bool isOnline = false;
try {
final List<InternetAddress> result = await InternetAddress.lookup('example.com');
isOnline = result.isNotEmpty && result[0].rawAddress.isNotEmpty;
} catch (e) {
isOnline = false;
}
return isOnline;
}
This is what I settled on for onPressed of my Login button (based on the suggestion of @doriansabo )
try {
isProcessing(true);
final connectivityStatus = await Connectivity().checkConnectivity();
debugPrint(connectivityStatus.name);
if (connectivityStatus == ConnectivityResult.none) {
// This logic for checking connectivity status once again after a 5
// milliseconds delay is required for iOS devices because of:
// https://github.com/fluttercommunity/plus_plugins/issues/852
// https://github.com/fluttercommunity/plus_plugins/issues/858
// TODO: Revert back to previous logic once these tickets are closed
await Future.delayed(const Duration(microseconds: 5));
// Delay of 1 microsecond yielded inconsistent result when we tap the
// login button very fast (right after logging out) and I was too lazy
// to test for 2, 3, and 4 microsecond
final newConnectivityStatus = await Connectivity().checkConnectivity();
debugPrint(newConnectivityStatus.name);
if (newConnectivityStatus == ConnectivityResult.none) {
isProcessing(false);
showSnackBar(
message: "Please connect to Internet before trying to Login",
type: SnackBarTypes.Error,
);
return;
}
}
...
The issue persists, any fix???
Unfortunately no updates yet!
same problem with version 3.0.2
. i am using flutter 3.7.0
.
i got this problem on iPhone 7 Plus with ios 15.7.3
, and iPhone 8 Plus with ios 15.1.0
the issue still happening flutter version: 3.7.5 ios version: 16.2
The issue still here, iOS 15.1, the plugin is very unreliable on iOS, we need fix.
To workaround the issue, you can add an empty onConnectivityChanged
listener somewhere in your code - after this, the method Connectivity().checkConnectivity()
will return a correct value.
Any updates in this topic?
same issue!
on 3.1.2
and 4.0.2
make class
import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
class ConnectivityManager {
factory ConnectivityManager() {
return _instance;
}
ConnectivityManager._internal();
static final ConnectivityManager _instance = ConnectivityManager._internal();
late StreamSubscription<dynamic> subscription;
ConnectivityResult result = ConnectivityResult.none;
void init() {
subscription = Connectivity()
.onConnectivityChanged
.listen((ConnectivityResult result) {
// Got a new connectivity status!
this.result = result;
});
}
}
And initialize in main.dart
ConnectivityManager().init();
and, call
final connectivityResult = ConnectivityManager().result;
/// bla bla ...
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days
Looks like this ticket is getting stale. Ahh, here is a comment to prevent it from auto-closing in 15 days.
It's really annoying that it closes automatically.
They say that it's not ideal to comment on an issue with comments like: "same problem here", but if we don't comment and/or move it, the issue is automatically closed.
Maybe I'm generalizing too much, but this is an example.
same here? Is there any solution?
Same issue here? any solution or any alternate package.
Same here! Did we find a solution yet? for me Its on MacOS Ventura 13.0.1 (22A400)
iOS 15.8 iPhone SE
Connection 2: received failure notification Connection 2: failed to connect 1:50, reason -1 Connection 2: encountered error(1:50)
iPhone 15 ios 17 same problem, any update?