initialize method
Initialize the SDK via native code All sensitive initialization logic is in the compiled binary
Implementation
Future<CoreInitResult> initialize({
String? apiKey,
String environment = 'production',
bool autoInitWithAdmin = true,
}) async {
try {
final result = await _channel.invokeMethod<Map<dynamic, dynamic>>('initialize', {
'apiKey': apiKey,
'environment': environment,
'autoInitWithAdmin': autoInitWithAdmin,
});
if (result != null) {
_initialized = result['success'] == true;
return CoreInitResult(
success: result['success'] as bool? ?? false,
code: result['code'] as String? ?? 'UNKNOWN',
message: result['message'] as String? ?? '',
);
}
return CoreInitResult(
success: false,
code: 'NULL_RESULT',
message: 'No result from native code',
);
} on PlatformException catch (e) {
return CoreInitResult(
success: false,
code: e.code,
message: e.message ?? 'Platform exception',
);
}
}