updateUser static method

dynamic updateUser({
  1. String transactionId = "",
})

Implementation

static updateUser({String transactionId = ""}) async {
  var iosDeviceInfo = await DeviceInfoPlugin().iosInfo;

  PackageInfo packageInfo = await PackageInfo.fromPlatform();
  String appVersion = packageInfo.version;
  String deviceId = iosDeviceInfo.identifierForVendor ?? "";

  PurchaseHelper.setAnalyticData("version", appVersion);
  PurchaseHelper.setAnalyticData("deviceId", deviceId);

  var oldDuration = await iCloudStorage.getString("usageMinutes") ?? "0";
  PurchaseHelper.setAnalyticData("usageMinutes", oldDuration);

  var data = {
    "device_id": deviceId,
    "first_seen": Pref.get("installation_time", 0) / 1000,
    "last_seen": DateTime.now().millisecondsSinceEpoch / 1000,
    "device_name": iosDeviceInfo.utsname.machine,
    "os_info": "${iosDeviceInfo.systemName} ${iosDeviceInfo.systemVersion}",
    "app_version": appVersion,
    "country": Get.deviceLocale?.countryCode ?? "",
    "lang": Get.deviceLocale?.languageCode ?? "",
    "purchase_history":
        jsonEncode((await Storekit2Helper.fetchPurchaseHistory())),
    "asa": PurchaseHelper.asaData,
    "package_name": await Helper.getPackageName(),
    "stats": PurchaseHelper.analyticData
  };

  if (transactionId != "") {
    data["original_transaction_id"] = transactionId;
  }

  HttpHelper.postRequest("https://apps.mzgs.net/inappuser/update-user", data);
}