颤振iOS RevenueCat未捕获异常';n内部一致性异常';

颤振iOS RevenueCat未捕获异常';n内部一致性异常';,ios,flutter,in-app-purchase,revenuecat,Ios,Flutter,In App Purchase,Revenuecat,我在控制台中遇到了以下错误: [Purchases] - INFO: There is no singleton instance. Make sure you configure Purchases before trying to get the default instance. *** Assertion failure in +[RCCommonFunctionality getPurchaserInfoWithCompletionBlock:], RCCommonFunctional

我在控制台中遇到了以下错误:

[Purchases] - INFO: There is no singleton instance. Make sure you configure Purchases before trying to get the default instance.
*** Assertion failure in +[RCCommonFunctionality getPurchaserInfoWithCompletionBlock:], RCCommonFunctionality.m:118
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must call setup first.'
*** First throw call stack:
(0x1a0379654 0x1a009bbcc 0x1a027c6ec 0x1a06c216c 0x1032908ac 0x1032cdf9c 0x1032cc0d4 0x105c3ae30 0x1053ef758 0x1056d58b4 0x1053f90ec 0x1053fb818 0x1a02f8134 0x1a02f7e50 0x1a02f752c 0x1a02f253c 0x1a02f1ba8 0x1aa461344 0x1a442d3e4 0x102c4069c 0x1a01798f0)
libc++abi.dylib: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001a016ed88 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1a016ed88 <+8>:  b.lo   0x1a016eda4               ; <+36>
    0x1a016ed8c <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1a016ed90 <+16>: mov    x29, sp
    0x1a016ed94 <+20>: bl     0x1a014dad0               ; cerror_nocancel
Target 0: (Runner) stopped.
Lost connection to device.

有什么我错过的吗?(但大多数时候它都能工作)

我发现了问题。因此,无论何时调用
getPurchaserInfo
,但如果
Purchaser.setup
尚未完成处理,则将触发此异常。感谢上面@Cesar的评论

就我而言,我发现问题在于:

  • 我有两个组分别处理IAP和业务逻辑
  • 一旦用户通过身份验证,IAP就会调用
    Purchases.setup
    。然后在主屏幕上,业务逻辑将通过执行
    getPurchaserInfo
    与服务器检查本地数据的有效性
  • 当internet连接不好并且
    getPurchaserInfo
    购买之前被Business logic bloc触发时,问题就出现了。安装程序
    完成处理

因此,我所做的解决方案是,确保一旦IAP bloc完成了
Purchases.setup
,Business logic bloc就开始初始化。例如,将它们放在等待每个进程的异步函数中。

你说的“启动时”是什么意思?还有,你在哪里打电话给getPurchaserInfo?在你的应用程序有机会调用购买之前,它已被调用。设置谢谢你的指针。我终于解决了这个问题。启动时意味着我在验证用户身份后立即调用它。我修正了这个问题以反映这一点。
 await Purchases.setDebugLogsEnabled(isDebugEnabled);
 await Purchases.setup(kRevenueCatApiKey, appUserId: uid);