setExtensionInfo method

  1. @override
Future<PitelSettings> setExtensionInfo(
  1. SipInfoData sipInfoData,
  2. PushNotifParams pushNotifParams
)
override

Implementation

@override
Future<PitelSettings> setExtensionInfo(
  SipInfoData sipInfoData,
  PushNotifParams pushNotifParams,
) async {
  //! WARNING: solution 2
  // final SharedPreferences prefs = await SharedPreferences.getInstance();
  // final sipInfoEncode = jsonEncode(sipInfoData);
  // final pnPushParamsEncode = jsonEncode(pnPushParams);
  // await prefs.setString("SIP_INFO_DATA", sipInfoEncode);
  // await prefs.setString("PN_PUSH_PARAMS", pnPushParamsEncode);

  final deviceTokenRes = await PushVoipNotif.getDeviceToken();
  final fcmToken = await PushVoipNotif.getFCMToken();

  final pnPushParams = PnPushParams(
    pnProvider: Platform.isAndroid ? 'fcm' : 'apns',
    pnParam: Platform.isAndroid
        ? pushNotifParams.bundleId
        : '${pushNotifParams.teamId}.${pushNotifParams.bundleId}.voip',
    pnPrid: deviceTokenRes,
    fcmToken: fcmToken,
  );

  this.sipInfoData = sipInfoData;
  pitelClient.setExtensionInfo(sipInfoData.toGetExtensionResponse());
  final pitelSetting = await pitelClient.registerSipWithoutFCM(pnPushParams);
  return pitelSetting;
}