iOS IAP还原只需几次尝试

iOS IAP还原只需几次尝试,ios,in-app-purchase,Ios,In App Purchase,我在我的应用中遇到了一个非常尴尬的应用内购买行为。 该应用程序是一个webview,因此我创建了一个webview并加载本地HTML文件 自上次更新以来,IAP恢复现在需要多次尝试,直到最终恢复特定产品。我有3个产品,我注意到我的第一个IAP需要1-2次尝试,直到它恢复,但其他2次恢复只有在我尝试恢复3-4-5-6-7次之后 在上一次更新中,还原代码没有任何更改,我在其他发现的问题中也没有找到任何线索 第二个问题: 如果我购买了所有3个产品,恢复一个产品是否应该恢复所有产品 更新: 这是我的密码

我在我的应用中遇到了一个非常尴尬的应用内购买行为。 该应用程序是一个webview,因此我创建了一个webview并加载本地HTML文件

自上次更新以来,IAP恢复现在需要多次尝试,直到最终恢复特定产品。我有3个产品,我注意到我的第一个IAP需要1-2次尝试,直到它恢复,但其他2次恢复只有在我尝试恢复3-4-5-6-7次之后

在上一次更新中,还原代码没有任何更改,我在其他发现的问题中也没有找到任何线索

第二个问题: 如果我购买了所有3个产品,恢复一个产品是否应该恢复所有产品

更新: 这是我的密码

func restorepources(){

func alertForRestorePurchases(uu结果:RestoreResults)->UIAlertController{

    if results.restoreFailedPurchases.count > 0 {
        print("Restore Failed: \(results.restoreFailedPurchases)")
        return alertWithTitle("Restore succesful", message: "Everything was restored.")
    } else if results.restoredPurchases.count > 0 {
        print("Restore Success: \(results.restoredPurchases)")

        var isSuccess = false
        for i in 0 ..< results.restoredPurchases.count
        {
            let pId = results.restoredPurchases[0].productId
            if pId == self.currentProductId
            {
                isSuccess = true

                if(pId == appDelegate.pId1)
                {
                    UserDefaultManager.setPurchaseStatus(flag: true)
                    self.purchaseTimer.invalidate()
                }
                else if(pId == appDelegate.pId2)
                {
                    UserDefaultManager.setPicaPurchaseStatus(flag: true)
                    self.purchaseTimer.invalidate()
                }
                else if(pId == appDelegate.pId3)
                {
                    UserDefaultManager.setPicaRealPurchaseStatus(flag: true)
                    self.purchaseTimer.invalidate()
                }

                makeJsScriptCall()
                return alertWithTitle("Activated!", message: "Everything was restored!")
            }
        }

        if(!isSuccess)
        {
            return alertWithTitle("Something went wrong", message: "This is the error that I get until I try restore 3-4 times")
        }

如果您能在出现问题的地方分享一些代码(或经过净化的示例),我将提供帮助,这将大大有助于获得反馈。非常感谢,以下是我所有与还原相关的函数。@如果您能分享一些代码(或经过净化的示例),AugustI将提供帮助如果您的代码出现问题,它将大大有助于获得反馈。非常感谢,以下是我所有与恢复相关的函数
    if results.restoreFailedPurchases.count > 0 {
        print("Restore Failed: \(results.restoreFailedPurchases)")
        return alertWithTitle("Restore succesful", message: "Everything was restored.")
    } else if results.restoredPurchases.count > 0 {
        print("Restore Success: \(results.restoredPurchases)")

        var isSuccess = false
        for i in 0 ..< results.restoredPurchases.count
        {
            let pId = results.restoredPurchases[0].productId
            if pId == self.currentProductId
            {
                isSuccess = true

                if(pId == appDelegate.pId1)
                {
                    UserDefaultManager.setPurchaseStatus(flag: true)
                    self.purchaseTimer.invalidate()
                }
                else if(pId == appDelegate.pId2)
                {
                    UserDefaultManager.setPicaPurchaseStatus(flag: true)
                    self.purchaseTimer.invalidate()
                }
                else if(pId == appDelegate.pId3)
                {
                    UserDefaultManager.setPicaRealPurchaseStatus(flag: true)
                    self.purchaseTimer.invalidate()
                }

                makeJsScriptCall()
                return alertWithTitle("Activated!", message: "Everything was restored!")
            }
        }

        if(!isSuccess)
        {
            return alertWithTitle("Something went wrong", message: "This is the error that I get until I try restore 3-4 times")
        }
    alert.addAction(UIAlertAction(title: "Purchase", style: .default , handler:{ (UIAlertAction)in
        self.purchase(.nonConsumablePurchase, atomically: true)
    }))

    alert.addAction(UIAlertAction(title: "Restore", style: .default , handler:{ (UIAlertAction)in
        self.restorePurchases()
    }))

    alert.addAction(UIAlertAction(title: "Dismiss", style: .cancel, handler:{ (UIAlertAction)in
    }))

    alert.popoverPresentationController?.sourceView = self.view
    self.present(alert, animated: true, completion: {
        print("completion block")
    })
}