initializeSDK static method
Initializes the SDK with the provided configuration parameters.
This method initializes the Mirrorfly SDK with the specified configuration parameters.
It is an asynchronous operation that returns a Future that completes with void
once the initialization is complete.
Parameters:
licenseKey
: The license key used for SDK initialization. Must not be null.iOSContainerID
: The iOSContainerID represents App Group ID for iOS app sharing data between app extensions and containing apps. Must not be null for iOS.storageFolderName
: The name of the storage folder to be used by the SDK. Defaults to "Mirrorfly".chatHistoryEnable
: Flag indicating whether chat history should be enabled. Defaults to false.enableMobileNumberLogin
: Flag indicating whether mobile number login should be enabled. Defaults to true.enableDebugLog
: Flag indicating whether debug logs should be enabled. Defaults to false.enablePrivateStorage
: Flag indicating whether private storage should be enable. Defaults to false.flyCallback
: A callback function to handle the response from the SDK initialization. Must not be null.
Returns:
A Future that completes with void
once the initialization is complete.
Throws:
- PlatformException if any of the required parameters are null or other exceptions.
Example usage:
await Mirrorfly.initializeSDK(
licenseKey: "your_license_key",
iOSAppGroupID: "your_app_group_id",
flyCallback: (response) {
if (response.isSuccess) {
print('SDK initialization successful');
} else {
print('SDK initialization failed: ${response.errorMessage}');
}
runApp(const MyApp());
},
);
Implementation
static Future<void> initializeSDK(
{required String licenseKey,
required String iOSContainerID,
String? storageFolderName = "Mirrorfly",
bool chatHistoryEnable = false,
bool enableMobileNumberLogin = true,
bool enableDebugLog = false,
bool enablePrivateStorage = false,
required Function(FlyResponse response) flyCallback}) {
var builder = InitializeSDKBuilder(
iOSContainerID: iOSContainerID,
licenseKey: licenseKey,
storageFolderName: storageFolderName,
chatHistoryEnable: chatHistoryEnable,
enableMobileNumberLogin: enableMobileNumberLogin,
enableDebugLog: enableDebugLog,
enablePrivateStorage: enablePrivateStorage);
isChatHistoryEnabled = chatHistoryEnable;
isPrivateStorageEnabled = enablePrivateStorage;
return FlyChatFlutterPlatform.instance.initializeSDK(builder, flyCallback);
}