attachToHostSdk method

  1. @override
Future<bool> attachToHostSdk({
  1. required bool enableIntegrationTesting,
})
override

Starts the Embrace SDK.

Implementation

@override
Future<bool> attachToHostSdk({required bool enableIntegrationTesting}) async {
  if (isStarted) {
    if (kDebugMode) {
      print('Embrace SDK has already started!');
    }
    return false;
  }

  _isStarted = true;

  debugPrint('Embrace Flutter SDK Version: $packageVersion');

  methodChannel.setMethodCallHandler(handleMethodCall);

  final success = await methodChannel.invokeMethod<bool?>(
        _attachSdkMethodName,
        {
          _enableIntegrationTestingArgName: enableIntegrationTesting,
          _embraceFlutterSdkVersionArgName: packageVersion,
          _dartRuntimeVersionArgName: _platform.version.replaceAll('"', ''),
        },
      ) ??
      false;
  if (!success) {
    if (kDebugMode) {
      print(
        'The Embrace SDK was not started in Android/iOS native code. '
        'This likely indicates a problem with your integration. We '
        'recommend reviewing your Application/AppDelegate classes to ensure '
        'Embrace.start is called for each native SDK. The Flutter SDK will '
        'attempt to initialize the native SDK regardless but your '
        'experience may be degraded by initializing late.',
      );
    }
  } else {
    if (kDebugMode) {
      print('Embrace Flutter SDK attached to host SDK successfully.');
    }
  }
  return success;
}