init static method
Future<void>
init(
- String appId,
- AppSettings appSettings, {
- required dynamic onSuccess(
- String successMessage
- required dynamic onError()?,
method initializes the settings required for CometChat
We suggest you call the init() method on app startup
appId
refers to your CometChat App ID.
region The region where the app was created.
Implementation
static Future<void> init(String appId, AppSettings appSettings,
{required Function(String successMessage)? onSuccess,
required Function(CometChatException e)? onError}) async {
try {
final arguments = {
'appId': appId,
'roles': appSettings.roles,
'region': appSettings.region,
'adminHost': appSettings.adminHost,
'clientHost': appSettings.clientHost,
'subscriptionType': appSettings.subscriptionType,
'autoEstablishSocketConnection':
appSettings.autoEstablishSocketConnection,
'sdkVersion': null,
'platform': null
};
final result = await channel.invokeMethod('init', arguments);
initializetestmessageStream();
nativeStream?.listen((event) {});
if (onSuccess != null) onSuccess(result);
} on PlatformException catch (p) {
_errorCallbackHandler(null, p, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
}