initialize method

Future<void> initialize(
  1. PalOptions palOptions,
  2. GlobalKey<NavigatorState> navigatorKey
)

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(_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);
  }
}