Session constructor

Session({
  1. required String appId,
  2. @Deprecated("Use [token] or [tokenFetcher] instead") String? signature,
  3. String? token,
  4. TokenFetcherHandler? tokenFetcher,
  5. bool? enablePushNotifications = false,
  6. MessageHandler? onMessage,
  7. Unreads? unreads,
  8. UnreadsChangeHandler? onUnreadsChange,
})

Implementation

Session({
  required this.appId,
  @Deprecated("Use [token] or [tokenFetcher] instead") this.signature,
  this.token,
  this.tokenFetcher,
  this.enablePushNotifications = false,
  this.onMessage,
  this.unreads,
  this.onUnreadsChange,
}) : _completer = Completer() {
  rootBundle
      .loadString('packages/talkjs_flutter/assets/version.txt')
      .then((version) {
    _headlessWebView = HeadlessInAppWebView(
        onWebViewCreated: _onWebViewCreated,
        onLoadStop: _onLoadStop,
        onConsoleMessage:
            (InAppWebViewController controller, ConsoleMessage message) {
          print("session [${message.messageLevel}] ${message.message}");
        },
        initialSettings: InAppWebViewSettings(
            applicationNameForUserAgent:
                'TalkJS_Flutter/${version.trim().replaceAll('"', '')}'));

    // Runs the headless WebView
    _headlessWebView!.run();
  });
}