ios - purchaserInfoUpdateListener 从不调用 RevenueCat
问题描述
我正在使用 RevenueCat 的 React Native SDK。
我正在遵循官方示例。
我可以在 iOS 上进行购买并得到You're all set. Your purchase was successful
提示。
问题是purchaserInfoUpdateListener
永远不会被调用,并且购买总是被catch
阻止,我无法验证我的代码中是否已成功购买。
可能是什么问题呢?
async componentDidMount() {
try {
this.purchaserInfoUpdateListener = (info) => {
console.log('purchaserInfoUpdateListener:: ', info )
checkIfPro(info);
};
this.shouldPurchasePromoProduct = async deferredPurchase => {
this.deferredPurchase = deferredPurchase;
};
Purchases.addPurchaserInfoUpdateListener(this.purchaserInfoUpdateListener);
Purchases.addShouldPurchasePromoProductListener(this.shouldPurchasePromoProduct);
} catch (e) {
console.log("Error handling");
}
}
async componentWillUnmount() {
Purchases.removePurchaserInfoUpdateListener(this.purchaserInfoUpdateListener);
Purchases.removeShouldPurchasePromoProductListener(this.shouldPurchasePromoProduct);
}
onPress={async () => {
const aPackage = this.state.offerings.current.availablePackages[0];
try {
const purchaseMade = await Purchases.purchasePackage(aPackage);
checkIfPro(purchaseMade); //never called
console.log('purchaseMade:: ',purchaseMade) //never called
} catch (e) {
if (!e.userCancelled) {
console.log(`Error handling ${JSON.stringify(e)}`);
} else {
console.log(`User cancelled ${JSON.stringify(e)}`);
}
}
}}
日志:
[Purchases] - DEBUG: No cached purchaser info, fetching
[Purchases] - DEBUG: there are no requests currently running, starting request GET
[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe
[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe/offerings
[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe/offerings 200
[Purchases] - DEBUG: Requesting products with identifiers: {(
[Purchases] - DEBUG: Products request finished
[Purchases] - DEBUG: Valid Products:
[Purchases] - DEBUG: 2567531 - <SKProduct: 0x281753720>
[Purchases] - DEBUG: com.colorfulNightLight.unlockAllFeatures - <SKProduct: 0x281753740>
[Purchases] - DEBUG: Invalid Product Identifiers - (
[Purchases] - DEBUG: 1 completion handlers waiting on products
[Purchases] - DEBUG: GET /v1/subscribers/$RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe 201
[Purchases] - DEBUG: Sending latest purchaser info to delegate
[Purchases] - DEBUG: serial request done: GET /subscribers/$RCAnonymousID%3Af68c1e27ec9548489acd081bbf178ebe, 0 requests left in the queue
[Purchases] - DEBUG: Vending offerings from cache
[Purchases] - DEBUG: Vending offerings from cache
[Purchases] - DEBUG: Vending purchaserInfo from cache
[Purchases] - DEBUG: Vending purchaserInfo from cache
[Purchases] - DEBUG: applicationDidBecomeActive
[Purchases] - DEBUG: Vending offerings from cache
[Purchases] - DEBUG: Vending offerings from cache
[Purchases] - DEBUG: makePurchase
[Purchases] - DEBUG: makePurchase - com.colorfulNightLight.unlockAllFeatures - Offering: Default
[Purchases] - DEBUG: PaymentQueue updatedTransaction: com.colorfulNightLight.unlockAllFeatures (null) ((null)) (null) - 0
[Purchases] - DEBUG: applicationDidBecomeActive
[Purchases] - DEBUG: applicationDidBecomeActive
[Purchases] - DEBUG: PaymentQueue updatedTransaction: com.colorfulNightLight.unlockAllFeatures 4 ((null)) 0 - 1
[Purchases] - DEBUG: Loaded receipt from file:///private/var/mobile/Containers/Data/Application/3C217C29-CDCE-4EBF-966C-
7ADB8B64CF1C/StoreKit/sandboxReceipt
[Purchases] - INFO: found 0 unsynced attributes for appUserID: $RCAnonymousID:f68c1e27ec9548489acd081bbf178ebe
[Purchases] - DEBUG: there are no requests currently running, starting request POST /receipts
[Purchases] - DEBUG: POST /v1/receipts
[Purchases] - DEBUG: POST /v1/receipts 400
[Purchases] - ERROR: The receipt is not valid.
[Purchases] - DEBUG: serial request done: POST /receipts, 0 requests left in the queue
[Purchases] - DEBUG: Finishing com.colorfulNightLight.unlockAllFeatures 4 (0)
[Purchases] - DEBUG: PaymentQueue removedTransaction: com.colorfulNightLight.unlockAllFeatures 4 (0 (null)) (null) - 1
[Purchases] - DEBUG: Vending offerings from cache
[Purchases] - DEBUG: makePurchase
[Purchases] - DEBUG: makePurchase - com.colorfulNightLight.unlockAllFeatures - Offering: Default
[Purchases] - DEBUG: PaymentQueue updatedTransaction: com.colorfulNightLight.unlockAllFeatures (null) ((null)) (null) - 0
[Purchases] - DEBUG: applicationDidBecomeActive
[Purchases] - DEBUG: applicationDidBecomeActive
解决方案
从日志中,您400 error The receipt is not valid.
在发送到 RevenueCat 时会收到一个。这是发生在模拟器还是物理设备上?
要在模拟器(iOS 14+)上进行测试,您需要在 XCode 中创建 StoreKit 配置并将您的证书上传到 RevenueCat:https ://docs.revenuecat.com/docs/apple-app-store#ios-14-only -在模拟器上测试
在物理设备上,您无需进行任何额外设置即可测试购买。
您的沙盒帐户也可能已损坏,您可以尝试在 App Store Connect 中创建新的沙盒用户。
推荐阅读
- c# - TabControl 的 BusyIndicator
- php - 更改/更改特定 URL
- c# - 将 Microsoft bot 框架连接到 Ms Teams(未在 Ms Teams 中显示主动消息)
- php - 如果输入表单由 For 循环显示,如何多次插入 Laravel
- java - Android Crashlytics 空指针异常
- xamarin - Azure DevOps 构建 Xamarin.Android 9.4.1.0 作为托管 macOS 映像中的目标
- python - 为模块创建新记录器是否仍使用根记录器名称?
- javascript - 如何使用 getelementbyid 从多个查询中获取多个数据
- python - 使用嵌套条件表达式
- oracle - 在 Oracle 中将多行合二为一