在 iOS 上获取 IAP 产品的空标题和描述

Getting empty title and description for IAP product on iOS

在我的应用程序获得 App Store Connect 批准之前,一切正常。

当我的 IAP 处于“准备提交”状态时,我的产品就很好了。但现在,它处于“已批准”状态,我的产品标题和描述都是空的。价格和标识符都可以。

即使在使用 Magic Weather example app from RevenueCat 时我也遇到了同样的行为。

这是我的代码:

Future<void> _initPlatformState() async {
    await Purchases.setup("******************************", appUserId: null);
    Purchases.addPurchaserInfoUpdateListener((info) {
      _checkIfVIP(info);
    });
    try {
      purchaserInfo = await Purchases.getPurchaserInfo();
      print('PurchaserInfo: ' + purchaserInfo.toString());
      //_checkIfVIP(purchaserInfo);
    } on PlatformException catch (e) {
      print('PlatformException: ' + e.toString());
    }
    print('is user vip? ' + isVIP.toString());
  }

  void _checkIfVIP(PurchaserInfo purchaserInfo) {
    if (purchaserInfo != null && purchaserInfo.entitlements.all['vip'] != null) {
      setIsVIP(purchaserInfo.entitlements.all['vip'].isActive);
    } else {
      setIsVIP(false);
    }
    notifyListeners();
  }

  Offerings _offerings;

  Future<Offerings> getOfferings() async {
    Offerings offerings;
    if (_offerings != null)
      offerings = _offerings;
    else {
      try {
        offerings = await Purchases.getOfferings();
      } on PlatformException catch (e) {
        print(e.toString());
      }
    }
    print(offerings.toString());
    return offerings;
  }

Future<void> doPurchase() async {
    try {
      if (_offerings != null) {
        _toggleLoadingState();
        PurchaserInfo purchaserInfo = await Purchases.purchasePackage(_offerings.current.monthly);
        // the native purchase window should open before going forward
        if (purchaserInfo.entitlements.all["vip"].isActive) {
          MainModel mainModel = Provider.of<MainModel>(context, listen: false);
          mainModel.setIsVIP(true);
          showDialog(
            context: context,
            builder: (BuildContext context) {
              return AlertDialog(
                title: new Text(S.current.welcome_to_the_vip_group),
                content: new Text(
                  S.current.purchase_success,
                  textAlign: TextAlign.center,
                ),
                actions: <Widget>[
                  new TextButton(
                    child: new Text(S.current.close),
                    onPressed: () => {popToPreviousPage(context)},
                  ),
                ],
              );
            },
          );
        } else {
          print('purchaserInfo.entitlements.all["vip"].toString());
          _toggleLoadingState();
        }
      }
    } on PlatformException catch (e) {
      _toggleLoadingState();
      var errorCode = PurchasesErrorHelper.getErrorCode(e);
      showDialog(
        context: context,
        builder: (BuildContext context) {
          if (errorCode == PurchasesErrorCode.purchaseCancelledError) {
            return AlertDialog(
              title: new Text(''),
              content: new Text(
                S.current.purchase_canceled_error,
                textAlign: TextAlign.center,
              ),
              actions: <Widget>[
                new TextButton(
                  child: new Text(S.current.close),
                  onPressed: () => Navigator.pop(context),
                ),
              ],
            );
          } else if (errorCode == PurchasesErrorCode.storeProblemError) {
            return AlertDialog(
              title: new Text(S.current.oops),
              content: new Text(S.current.purchase_store_problem_error(Platform.isAndroid ? 'Google Play' : 'App Store')),
              actions: <Widget>[
                new TextButton(
                  child: new Text(S.current.close),
                  onPressed: () => Navigator.pop(context),
                ),
              ],
            );
          } else {
            return AlertDialog(
              title: new Text(S.current.oops),
              content: new Text(S.current.purchase_default_error),
              actions: <Widget>[
                new TextButton(
                  child: new Text(S.current.close),
                  onPressed: () => Navigator.pop(context),
                ),
              ],
            );
          }
        },
      );
      print('isLoadingSomething = ' + e.toString());
    }
  }

这是来自 Magic Weather 应用程序的日志:

flutter run
Launching lib/main.dart on iPhone de **** in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: ********
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         6,7s
Xcode build done.                                           12,1s
Installing and launching...                                        13,3s
Syncing files to device iPhone de ******...                      75ms

Flutter run key commands.
r Hot reload. 
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

An Observatory debugger and profiler on iPhone de ***** is available at: http://127.0.0.1:50626/3xLvY2V4t7c=/
[Purchases] - DEBUG: ℹ️ Debug logging enabled
[Purchases] - DEBUG: ℹ️ SDK Version - 3.11.1
[Purchases] - DEBUG:  Initial App User ID - (null)
[Purchases] - DEBUG: ℹ️ Sending latest PurchaserInfo to delegate.
[Purchases] - DEBUG: ℹ️ Delegate set
[Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET /subscribers/$RCAnonymousID0X0P+09303b005bcc24f1a83115fa2a44c4a11
[Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/$RCAnonymousID:9303b005bcc24f1a83115fa2a44c4a11
[Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/$RCAnonymousID:9303b005bcc24f1a83115fa2a44c4a11/offerings
The Flutter DevTools debugger and profiler on iPhone de ****** is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:50626/3xLvY2V4t7c=/
[connection] nw_endpoint_handler_set_adaptive_read_handler [C1.1 54.90.18.6:443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for read_timeout failed
[connection] nw_endpoint_handler_set_adaptive_write_handler [C1.1 54.90.18.6:443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for write_timeout failed
[Purchases] - DEBUG: ℹ️ API request completed with status: GET /v1/subscribers/$RCAnonymousID:9303b005bcc24f1a83115fa2a44c4a11 200
[Purchases] - DEBUG: ℹ️ Serial request done: GET /subscribers/$RCAnonymousID0X0P+09303b005bcc24f1a83115fa2a44c4a11, 0 requests left in the queue
[Purchases] - DEBUG: ℹ️ API request completed with status: GET /v1/subscribers/$RCAnonymousID:9303b005bcc24f1a83115fa2a44c4a11/offerings 200
[Purchases] - DEBUG: ℹ️ Requesting products from the store with identifiers: {(
    0001
)}
[Purchases] - DEBUG: ℹ️ Products request finished.
[Purchases] - DEBUG:  Retrieved SKProducts: 
[Purchases] - DEBUG:  0001 - <SKProduct: 0x280ea0030>
[Purchases] - DEBUG: ℹ️ 1 completion handlers waiting on products
[Purchases] - DEBUG: ℹ️ Vending PurchaserInfo from cache.
[Purchases] - DEBUG: ℹ️ Vending Offerings from cache

在 Android 上一切都很好,在 App Store Connect 上似乎一切都很好。

我也在他们的 github 页面 (here and here) 上报告了这个问题,但没有任何帮助。

知道会发生什么吗?我什至尝试更改我的产品标题以查看是否可以修复它,但没有成功。

数周以来一直在苦苦挣扎。不知道怎么办了。

原来 flutter SDK 上的某些内容已损坏。我删除并重新下载了flutter SDK,它成功了。

奇怪。