flutter 付款后立即运行功能

pinkon5k  于 2022-11-17  发布在  Flutter
关注(0)|答案(1)|浏览(122)

我正在使用purchases_flutterrevenueCat在我的应用程序上提供订阅。
如何在付款后立即运行功能?

  • 谢谢-谢谢
azpvetkf

azpvetkf1#

使用RevenueCat,您可以在购买行之后执行任何操作。

static Future<Package?> makePurchases(Package? package, ValueNotifier<bool> isWaiting) async {
        try {
          isWaiting.value = true;
          purchaserInfo = await Purchases.purchasePackage(package!);
          await Purchases.syncPurchases();
          if (purchaserInfo.entitlements.all["Pro"]!.isActive) {
            purchaserInfo = await Purchases.purchasePackage(package);
          }
    
          // here purchase is done
          // do something
    
          isWaiting.value = false;
        } on PlatformException catch (e) {
          var errorCode = PurchasesErrorHelper.getErrorCode(e);
          if (errorCode != PurchasesErrorCode.purchaseCancelledError) {}
    
          isWaiting.value = false;
        }
        isWaiting.value = false;
        return null;
      }

相关问题