credentialLogin method

  1. @Deprecated("Use connectWithCredential(..) instead")
void credentialLogin(
  1. CredentialConfig config
)

Uses the provided config to send a credential 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 connectWithCredential(..) instead")
void credentialLogin(CredentialConfig config) {
  storedCredentialConfig = config;
  var uuid = const Uuid().v4();
  var user = config.sipUser;
  var password = config.sipPassword;
  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(
    login: user,
    passwd: password,
    loginParams: [],
    userVariables: notificationParams,
    attachCall: "true",
  );
  var loginMessage = LoginMessage(
      id: uuid,
      method: SocketMethod.LOGIN,
      params: loginParams,
      jsonrpc: JsonRPCConstant.jsonrpc);

  String jsonLoginMessage = jsonEncode(loginMessage);
  if (isConnected()) {
    txSocket.send(jsonLoginMessage);
  } else {
    _connectWithCallBack(null, () {
      txSocket.send(jsonLoginMessage);
    });
  }
}