initializeSDK method
Future<void>
initializeSDK(
- InitializeSDKBuilder builder,
- dynamic callback(
- FlyResponse response
override
Initializes the SDK with the specified configuration and callback.
This method configures the SDK using the provided InitializeSDKBuilder settings. It is crucial
to invoke this method at the start of your application to ensure the SDK is correctly set up.
The callback
is executed once the initialization process is complete, providing feedback on
the success or failure of the operation.
builder
: The InitializeSDKBuilder instance containing the SDK configuration settings.
callback
: A callback function that receives a FlyResponse indicating the result of the SDK initialization.
Throws UnimplementedError if the method has not been implemented in the subclass.
Implementation
@override
Future<void> initializeSDK(InitializeSDKBuilder builder,
Function(FlyResponse response) callback) async {
bool? res;
enableDebugLog = builder.enableDebugLog;
if (!_messageOnReceivedStreamController.hasListener) {
addStreamsAllToStreamController();
}
try {
res = await mirrorFlyMethodChannel.invokeMethod<bool>(
'initializeSDK', builder.build());
LogMessage.d("initializeSDK", res);
callback.call(
FlyResponse(true, FlyConstants.empty, "initializeSDK Successfully"));
// return res;
return;
} on PlatformException catch (e) {
LogMessage.d("Platform Exception =", " $e");
callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
FlyException(e.code, e.message, e.details)));
// return res;
return;
} on Exception catch (e) {
LogMessage.d("Exception ", " $e");
callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
FlyException(FlyErrorCode.unHandle, FlyErrorMessage.unHandle, e)));
// return res;
return;
}
}