tokenLogin method

  1. @Deprecated("Use connectWithToken(..) instead")
void tokenLogin(
  1. TokenConfig config
)

Uses the provided config to send a token login message to the Telnyx backend. If successful, the gateway registration process will start.

May return a TelnyxSocketError in the case of an authentication error

Implementation

@Deprecated("Use connectWithToken(..) instead")
void tokenLogin(TokenConfig config) {
  storedTokenConfig = config;
  var uuid = const Uuid().v4();
  var token = config.sipToken;
  var fcmToken = config.notificationToken;
  ringBackpath = config.ringbackPath ?? "";
  ringtonePath = config.ringTonePath ?? "";
  UserVariables? notificationParams;
  _autoReconnectLogin = config.autoReconnect ?? true;

  if (defaultTargetPlatform == TargetPlatform.android) {
    notificationParams = UserVariables(
        pushDeviceToken: fcmToken, pushNotificationProvider: "android");
  } else if (defaultTargetPlatform == TargetPlatform.iOS) {
    notificationParams = UserVariables(
        pushDeviceToken: fcmToken, pushNotificationProvider: "ios");
  }

  var loginParams = LoginParams(
      loginToken: token,
      loginParams: [],
      userVariables: notificationParams,
      sessionId: sessid,
      attachCall: "true");
  var loginMessage = LoginMessage(
      id: uuid,
      method: SocketMethod.LOGIN,
      params: loginParams,
      jsonrpc: JsonRPCConstant.jsonrpc);

  String jsonLoginMessage = jsonEncode(loginMessage);
  _logger.i('Token Login Message $jsonLoginMessage');
  if (isConnected()) {
    txSocket.send(jsonLoginMessage);
  } else {
    _connectWithCallBack(null, () {
      txSocket.send(jsonLoginMessage);
    });
  }
}