initialize method
initialize the pal sdk
a session UID string is generated by the server to identify the current user
navigatorKey
the navigator key we needs to show the video as an overlay
Implementation
Future<void> initialize(
PalOptions palOptions,
GlobalKey<NavigatorState> navigatorKey,
) async {
try {
_palSdk ??= PalSdk.fromKey(navigatorKey: navigatorKey);
_httpClient ??= HttpClient.create(
palOptions.serverUrl ?? _serverUrl,
palOptions.apiKey,
);
_eventApi ??= PalEventApi(_httpClient!);
_sessionApi ??= PalSessionApi(
_httpClient!,
await SharedPreferences.getInstance(),
);
_triggeredEventApi ??= PalTriggeredEventApi(_httpClient!);
await _sessionApi!.initSession();
} catch (err, stack) {
debugPrint("error initializing pal: $err");
debugPrintStack(stackTrace: stack);
}
}