RevenueCat Flutter 配置错误

问题描述 投票:0回答:1

我按如下方式初始化代码,但收到此错误:

您的配置有问题。检查潜在错误以获取更多详细信息。你的配置有问题。在 RevenueCat 仪表板中注册的所有产品都无法从 App Store Connect(或 StoreKit 配置文件,如果正在使用)中获取。

代码:

Future<void> main() async {
  runApp(const MyApp());

  await _configureSdk();
}

Future<void> _configureSdk() async {
  await Purchases.setLogLevel(LogLevel.debug);

  PurchasesConfiguration? configuration;

  if (Platform.isAndroid) {
    //
  } else if (Platform.isIOS) {
    configuration = PurchasesConfiguration('apikey');
  }

  if (configuration != null) {
    await Purchases.configure(configuration);
    print('configure');
 await RevenueCatUI.presentPaywallIfNeeded('Premium');
  }
}
await RevenueCatUI.presentPaywallIfNeeded('Premium');
ElevatedButton(
                onPressed: () async {
                  await RevenueCatUI.presentPaywallIfNeeded('Premium');
                },
                child: Text('purchases'))

我尝试在单击按钮后以这种方式打开付费专区页面,但出现了相同的错误。

flutter dart revenuecat
1个回答
0
投票

我认为您的配置代码需要使用 initState 方法在应用程序状态中调用,而不是在 main 中调用,如下所示:

 @override
  void initState() {
    super.initState();
    _configureSdk();
  }


Future<void> _configureSdk() async {
  await Purchases.setLogLevel(LogLevel.debug);

  PurchasesConfiguration? configuration;

  if (Platform.isAndroid) {
    //
  } else if (Platform.isIOS) {
    configuration = PurchasesConfiguration('apikey');
  }

  if (configuration != null) {
    await Purchases.configure(configuration);
    print('configure');
 await RevenueCatUI.presentPaywallIfNeeded('Premium');
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.