Android平台上使用RevenueCat时在提交/receiptsPOST请求时出现错误520
创始人
2024-10-09 13:32:37
0
  1. 首先确认你的API key和RSA Key是否已正确设置,特别是在生产环境中需要注意。也可以尝试在不同的环境中重新设置这些密钥,包括在测试环境和生产环境中使用不同的密钥。

  2. 如果以上步骤均无效,可以尝试增加retry逻辑来解决错误520,代码示例如下:

RevenueCatClient client = Purchases.sharedInstance().getRevenueCatClient(); client.addPurchasesUpdatedListener(purchases -> {

final List updatedPurchases = purchases.getPurchasesList();
final List newPurchases = new ArrayList<>();

for (Purchase updatedPurchase : updatedPurchases) {
    if (isRelevantNewPurchase(updatedPurchase)) {
        newPurchases.add(updatedPurchase);
    }
}

if (!newPurchases.isEmpty()) {
    client.postReceipts(newPurchases, new ReceiptPostResponseListener() {
        @Override
        public void onReceived(List postDetails) {
            // TODO handle success
        }

        @Override
        public void onError(Error error) {
            if (error.getCode() == 520) {
                retryReceiptPost(newPurchases, error);
            } else {
                // TODO handle error
            }
        }
    });
}

});

private void retryReceiptPost(List newPurchases, Error error) { // Log the error for debugging Log.e(TAG, "Error " + error.getCode() + " when posting receipts.");

// Retry the post a maximum of 3 times with a 5 second delay in between
int retryCount = 0;
while (retryCount < 3) {
    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        // ignore
    }
    RevenueCatClient client = Purchases.sharedInstance().getRevenueCatClient();
    client.postReceipts(newPurchases, new ReceiptPostResponseListener() {
        @Override
        public void onReceived(List postDetails) {
            // TODO handle success
        }

        @Override
        public void onError(Error error) {

相关内容

热门资讯

今日科普!微信卡五星辅助器,微... 今日科普!微信卡五星辅助器,微乐自建房脚本免费入口(开挂自建房)攻略;1.微信卡五星辅助器 选牌创建...
重大通报!微乐自建房辅助工具挂... 重大通报!微乐自建房辅助工具挂,微乐小程序免费黑科技(开挂自建房)app1、打开软件启动之后找到中间...
让我来分享经验!微乐自建房辅助... 让我来分享经验!微乐自建房辅助工具免费app,微乐自建房脚本免费入口(开挂自建房)脚本1、微乐自建房...
记者揭秘!微乐小程序自建房辅助... 记者揭秘!微乐小程序自建房辅助工具插件,微乐自建房脚本免费入口(开挂自建房)软件微乐小程序自建房辅助...
必看攻略!微乐自建房辅助工具免... 必看攻略!微乐自建房辅助工具免费app,微乐家乡麻将自建房辅助app(开挂自建房)攻略1、每一步都需...
必备攻略!微乐家乡麻将自建房辅... 必备攻略!微乐家乡麻将自建房辅助app,微乐家乡麻将自建房辅助app(开挂自建房)技巧1、必备攻略!...
查到实测辅助!微信卡五星辅助器... 查到实测辅助!微信卡五星辅助器,微乐家乡麻将自建房辅助app(开挂自建房)教程1、超多福利:超高返利...
传递经验!微乐自建房辅助工具挂... 传递经验!微乐自建房辅助工具挂,微乐小程序免费黑科技(开挂自建房)技巧1、操作简单,无需微乐自建房辅...
一分钟教你!微信卡五星辅助器,... 一分钟教你!微信卡五星辅助器,微乐家乡麻将自建房辅助app(开挂自建房)插件1、这是跨平台的微乐家乡...
传递经验!微乐小程序自建房辅助... 传递经验!微乐小程序自建房辅助工具插件,微乐自建房脚本免费入口(开挂自建房)脚本传递经验!微乐小程序...