init static method

Future<void> init(
  1. String token,
  2. String? secretKey,
  3. String? keyId,
  4. bool debug, [
  5. String platform = 'FLUTTER',
  6. String? packageVersion,
])

Initialize the native SDK with project token Optionally pass the client SDK platform and version so native Android can be configured before init

Implementation

static Future<void> init(
  String token,
  String? secretKey,
  String? keyId,
  bool debug, [
  String platform = 'FLUTTER',
  String? packageVersion,
]) async {
  try {
    final Map<String, dynamic> arguments = {
      'token': token,
      'debug': debug,
    };

    // Only include secretKey and keyId if they are provided
    if (secretKey != null) {
      arguments['secretKey'] = secretKey;
    }
    if (keyId != null) {
      arguments['keyId'] = keyId;
    }
    // Provide SDK platform and version so Android can call configureSDK before init
    arguments['platform'] = platform;
    if (packageVersion != null) {
      arguments['packageVersion'] = packageVersion;
    }

    var res = await _channel.invokeMethod('init', arguments);
    developer.log(res.toString(), name: packageName);
    developer.log('Linkrunner initialized successfully 🔥', name: packageName);
  } on PlatformException catch (e) {
    developer.log('Failed to initialize native SDK: ${e.message}',
        error: e, name: packageName);
    rethrow;
  }
}