首页 > 解决方案 > 购买促销优惠(苹果):签名无效(SKErrorDomain 错误 12。)

问题描述

首先,我们实施了基本订阅和免费试用(介绍性优惠),并且都运行良好。在那之后,我们实现了Promotional Offer这个问题:即使我们遵循 Apple 在他们的文档中提供的指南(从上到下),我们总是得到同样的错误,即“签名无效。”。

("Error: The operation couldn’t be completed. (SKErrorDomain error 12.)"

提及:

以下是申请优惠的基本方法:

    
    func proceedToApplyOffer(signatureResult: PromotionalOfferSignatureResponse, username: String, completion: @escaping ((_ purchaseResult: Result<PurchaseDetails>) -> ())) {
        if #available(iOS 12.2, *) {
            
            self.getAppleProducts() {
                productsResult in
                
                // Get the apple products in order to be able to create the discount object
                
                switch productsResult {
                case .success(products: let products):
                    
                    // Create the discount object with which the purchase will be made
                    
                    guard let monthlyProduct: SKProduct = products.first(where: { $0.productIdentifier == self.monthlyProductIdentifier}) else { return }
                    let discount = SKPaymentDiscount(identifier: self.promotionalOfferIdentifier, keyIdentifier: self.keyIdentifier, nonce: signatureResult.nonce, signature: signatureResult.signature, timestamp: NSNumber(value: signatureResult.timestamp))
                    let swiftyDiscount = PaymentDiscount(discount: discount)
                    
                    self.paymentService.purchaseProductWithDiscount(product: monthlyProduct, username: username, discount: swiftyDiscount) {
                        result in
                        switch result {
                        
                        case .error(error: let skError):
                            completion(.error(skError))
                            
                        case .success(purchase: let purchaseDetails):
                            completion(.success(purchaseDetails))
                        }
                    }
                case .error(error: let error):
                    completion(.error(error))
                }
            }
        }
        else {
            debugPrint("Not available on current OS version")
        }
    }

我知道以前有人问过这个问题(我都读过),但他们没有任何答案,我希望这个问题会有答案,因为我得出的结论是,即使是在 apple.developer 上发布的问题论坛仍未得到答复。我将不胜感激任何帮助,任何想法谢谢

标签: iosswiftin-app-purchase

解决方案


推荐阅读