i have a weird problem with dio package for flutter on iOS device. i wrote an app which sends a GET request to a url. everything works perfectly on Android but looks like the request doesn't go thru on iOS. nothing happens no error nothing at all. i had the same problem on android too but i found out that i forgot to add INTERNET permission into my manifest file. i'm guessing the same situation occurring in iOS.
is there any INTERNET permission in iOS that i need to add info.plist ?
void _checkVersionAndPreferences() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String prefsRes = prefs.getString('access_token') ?? '';
String buildNumber = _packageInfo.buildNumber ?? '1';
Dio dio = Dio();
_cancelToken = CancelToken();
Future.delayed(Duration(seconds: 10), () {
if (_getRequestSuccess == false) {
_cancelToken.cancel();
_checkVersionAndPreferences();
_showSnackBar(
content: 'تلاش مجدد برای برقراری ارتباط',
duration: Duration(seconds: 3),
leading: Icon(Icons.refresh, color: Colors.black));
}
});
Response response = await dio.get(
'https://snapmelk.com/api/v1/panel/checkVersion/' + buildNumber,
cancelToken: _cancelToken);
try {
Map respJson = jsonDecode(response.data);
setState(() {
_getRequestSuccess = true;
});
if (respJson['error']) {
_showSnackBar(
content:
(respJson['errorMsg'] != null && respJson['errorMsg'] != '')
? respJson['errorMsg']
: 'خطا در اتصال دریافت اطلاعات آخرین نسخه',
leading: Icon(Icons.warning),
backgroundColor: Colors.red,
textColor: Colors.white);
} else {
if (respJson['NewUpdate']) {
_checkDialogAnswer(respJson, prefsRes);
} else {
_checkPrefs(prefsRes);
}
}
} catch (e) {
_showSnackBar(
content: 'خطا در اتصال با سرور. لطفا در زمانی دیگر مراجعه کنید',
leading: Icon(Icons.warning),
backgroundColor: Colors.red,
textColor: Colors.white);
}
}
.resume()
on a URLSessionTask, but mixing in dio and flutter, it's not obvious what you're actually calling. There is no special "internet" permission in iOS (and if there were, you'd get an error). We need to see the code. – Shenika_checkDialogAnswer
,_checkPrefs
, or_showSnackBar
), or that you're not actually calling this method at all (a very common mistake that leads to "nothing happens"). Add logging; see what does happen. – Shenika