简体   繁体   English

应用购买订阅验证中的应用商店失败

[英]App store in app purchase subscription validation fail

Using: 使用:

For purchasing: react-native-in-app-utils 购买: react-native-in-app-utils

For validation: iap-receipt-validator 验证: iap-receipt-validator

After successfully purchase a subscription, I would like to validate it every time user enters the app. 成功购买订阅后,我想在用户每次进入应用程序时对其进行验证。

receiptData returns the correct receipt string. receiveData返回正确的收据字符串。

InAppUtils.receiptData((error, receiptData)=> {
            if(error) {
            } else {
                IOSReceiptValidator.validate(receiptData).then(function (result) {
                }).catch(function (error) {
                });
            }
        });

IOSReceiptValidator: IOSReceiptValidator:

static async validate(receiptData) {
        try {
            const validationData = await validateReceipt(receiptData);
            console.log(validationData);
        } catch(err) {
            console.log(err.valid, err.error, err.message) // Here is the error
        }
    }

Validation fails, every time, 每次验证失败,

Error: 错误:

"Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'." “无法在'FileReader'上执行'readAsText':参数1不是'Blob'类型。”

I've tried to look for other issues with the libraries I'm using, but no issue was found. 我尝试使用正在使用的库查找其他问题,但未发现问题。 I'm not sure, but maybe is has something to do with debugging on Chrome? 我不确定,但也许与Chrome上的调试有关? (On Real device, just debugging in Chrome) Anyone has any idea? (在Real设备上,只需在Chrome中调试)有人有任何想法吗?

Thanks. 谢谢。

If anyone is facing the same issue, I've used "react-native-fetch-blob" to fix this. 如果有人遇到相同的问题,我已经使用“ react-native-fetch-blob”来解决。

POST to this URL: 发布到该URL:

const url = isProduction ? "https://buy.itunes.apple.com/verifyReceipt" : "https://sandbox.itunes.apple.com/verifyReceipt";

With content: 带有内容:

{"receipt-data": receiptData, password: password}

And wait for response 0 for validation. 并等待响应0进行验证。

As documented here: https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html 如此处所述: https : //developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

resolved. 解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM