use*_*845 5 in-app-purchase flutter
我正在尝试为我的 Flutter 应用程序使用 in_app_purchase 插件(https://pub.dev/packages/in_app_purchase)。
调用 queryProductDetails(ids) 工作得很好,但是在调用 queryPastPurchases() 时我得到以下异常:
PlatformException (PlatformException(storekit_no_receipt, Cannot find receipt for the current main bundle., null))
Run Code Online (Sandbox Code Playgroud)
似乎这是异常的来源:https : //github.com/flutter/plugins/blob/master/packages/in_app_purchase/ios/Classes/FIAPReceiptManager.m
值得一提的是:我已经在 App-Store-Connect 中设置了一个 IAP。此 IAP 尚未发送给 Apple 批准。应用程序正在开发中,使用 TestFlight 和 beta 测试人员进行测试。
另一个问题是,这个异常不会在 try-catch 语句中出现(请参阅下面的代码),而只会在检查 VSCode 中的“所有异常”选项时由环境引起...
在模拟器和真实设备上测试。
[更新]:在插件的objective-c代码中添加了断点,看到receiptURL指向“sandboxReceipt”。所以也许是因为我不使用沙箱用户?
Future<void> _getPastPurchases() async {
try {
final QueryPurchaseDetailsResponse response = await InAppPurchaseConnection.instance.queryPastPurchases();
if (response.error != null) {
// Handle the error
print(response.error.toString());
}
print('response = ' + response.toString());
for (PurchaseDetails purchase in response.pastPurchases) {
if (Platform.isIOS) {
//InAppPurchaseConnection.instance.completePurchase(purchase);
}
}
setState(() {
_purchases = response.pastPurchases;
});
} on PlatformException catch(err) {
print(err.toString());
}
catch (err) {
print(err.toString());
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
530 次 |
| 最近记录: |