initSdk static method
Provides a way to initialize the SDK with a specific channel ID by platform Android and iOS
Call this method first elsewhere subsequent calls will fail
Providing a androidChannelId
and iosChannelId
is mandatory, please visit your account to find
the identifiers
Implementation
static Future<bool?> initSdk(String androidChannelId, String iosChannelId, String? userId,
[Map<String, dynamic>? properties, Map<String, dynamic>? hooks]) {
_channel.setMethodCallHandler(channelHandler);
Map<String, String>? mapHooksId;
if (hooks != null) {
mapHooksId = <String, String>{};
hooks.forEach((key, value) {
if (key == "version") {
mapHooksId![key] = value.toString();
} else {
// Random UUID
String uuid = UniqueKey().toString();
hooksRegistry[uuid] = value;
mapHooksId![key] = uuid;
}
});
}
if (Platform.isIOS) {
return _channel.invokeMethod('initSdk', [iosChannelId, userId, _formatDates(properties), mapHooksId]);
} else if (Platform.isAndroid) {
return _channel.invokeMethod('initSdk', [androidChannelId, userId, _formatDates(properties), mapHooksId]);
}
return Future.value(false);
}