Flutter on iOS: How to trigger pop-up for allowing local network access

Viewed 842

Is there a way to trigger the pop-up window on an iOS device to allow the connection to other devices on the local network or at least to check the status of the local network permission? My first idea was to use the permission_handler package for flutter, but this doesn't provide the option for the local network permission. pop-up window local network permission in settings

2 Answers

This may help. The solution that I have is more specific to accessing locally soft access points (soft AP) on an Internet of Things (IoT) type of hardware.

Once I connect the phone to a soft access point, I then make an http.get call to the "soft AP" with http://10.10.0.1/

By making this call, it immediately fails and pops up this dialog that you're referring too.

I forward to generic widget page with an image that's clickable to the iOS Settings.

I used https://pub.dev/packages/app_settings

Upon pressed, I call this code:

AppSettings.openWIFISettings();

It goes to the iOS screen that the user then allows.

Trigger local network permission popup - Working code for Flutter using Socket and IP address of the device itself:

    import 'package:network_info_plus/network_info_plus.dart';
    import 'dart:io';
try{
    
    var deviceIp = await NetworkInfo().getWifiIP();
         
    
          Duration? timeOutDuration = Duration(milliseconds: 100);
          await Socket.connect(deviceIp, 80, timeout: timeOutDuration);
        } catch (e) {
          print(
              'Exception..');
        }
Related