initialize method
Initializes the TIKI SDK.
Use this method to initialize the TIKI SDK with the specified publishingId, id, and origin.
You can also provide an optional onComplete
closure that will be executed once the initialization process is complete.
- Parameters:
- publishingId: The publishingId for connecting to the TIKI cloud.
- id: The ID that uniquely identifies your user.
- onComplete: An optional closure to be executed once the initialization process is complete.
- origin: The default origin for all transactions. Defaults to
Bundle.main.bundleIdentifier
if null.
- Throws:
TikiSdkError
if the initialization process encounters an error.
Implementation
Future<void> initialize(String publishingId, String id,
{Function? onComplete = null,
String? origin = null,
String? dbDir = null}) async {
WidgetsFlutterBinding.ensureInitialized();
FlutterKeyStorage keyStorage = FlutterKeyStorage();
String address = await core.TikiSdk.withId(id, keyStorage);
origin ??= (await PackageInfo.fromPlatform()).packageName;
String dbFile = "${(dbDir ?? await _dbDir())}/$address.db";
CommonDatabase database = sqlite3.open(dbFile);
_core =
await core.TikiSdk.init(publishingId, origin, keyStorage, id, database);
if (onComplete != null) onComplete();
}