setAllowInternetConnection static method

Future<void> setAllowInternetConnection(
  1. bool allowInternetConnection
)

Enables or disables SDK access to the internet.

When enabled, the SDK may perform offboard operations such as checking for content updates. Disabling internet access prevents those operations from starting.

This function needs to be awaited as it may perform asynchronous operations.

Parameters

  • allowInternetConnection: set true to allow SDK network access, false to block it.

Also see:

Implementation

static Future<void> setAllowInternetConnection(
  bool allowInternetConnection,
) async {
  GemKitPlatform.instance.registerEventHandler(
    offBoardListener.id,
    offBoardListener,
  );

  if (GemKitPlatform.instance.androidVersion > -1) {
    await GemKitPlatform.instance
        .getChannel(mapId: -1)
        .invokeMethod<bool>(
          'networkProviderCall',
          jsonEncode(<String, dynamic>{
            'action': 'setUserDisabledNetwork',
            'disabled': !allowInternetConnection,
          }),
        );
  }

  staticMethod(
    'SdkSettings',
    'setAllowConnection',
    args: <String, dynamic>{
      'allow': allowInternetConnection,
      'listener': offBoardListener.id,
    },
  );

  _offBoardListener = offBoardListener;
  if (allowInternetConnection) {
    unawaited(NetworkProvider.refreshNetwork());
  }
}