From c0d12ce636034e943917abc0b5bdf05ebdbef9ec Mon Sep 17 00:00:00 2001 From: zeng Date: Thu, 18 Dec 2025 16:14:32 +0800 Subject: [PATCH] no message --- JXIAPManager.podspec | 2 +- Sources/JXIAPManager.swift | 46 +++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/JXIAPManager.podspec b/JXIAPManager.podspec index 19fd1aa..90958ad 100644 --- a/JXIAPManager.podspec +++ b/JXIAPManager.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |spec| spec.name = "JXIAPManager" - spec.version = "0.0.1" + spec.version = "0.0.2" spec.summary = "JXIAPManager内购小工具" spec.description = <<-DESC diff --git a/Sources/JXIAPManager.swift b/Sources/JXIAPManager.swift index 422aab7..19ade7f 100644 --- a/Sources/JXIAPManager.swift +++ b/Sources/JXIAPManager.swift @@ -1,34 +1,34 @@ import UIKit import StoreKit -@objc public protocol JXIAPManagerDelegate { +public protocol JXIAPManagerDelegate: AnyObject { /// 购买成功 - @objc optional func jx_iapPaySuccess(productId: String, receipt: String, transactionIdentifier: String) + func jx_iapPaySuccess(productId: String, receipt: String, transactionIdentifier: String) /// 购买失败 - @objc optional func jx_iapPayFailed(productId: String, code: JXIAPManagerCode, msg: String?) + func jx_iapPayFailed(productId: String, code: JXIAPManager.ErrorCode, msg: String?) /// 恢复商品(仅限永久有效商品) - @objc optional func iapPayRestore(productIds: [String], transactionIds: [String]) -// /// 加载 -// @objc optional func iapPayShowHud() -// /// 系统错误 -// @objc optional func iapSysWrong() -// /// 验证成功 -// @objc optional func verifySuccess() -// /// 验证失败 -// @objc optional func verifyFailed() + func iapPayRestore(productIds: [String], transactionIds: [String]) } -@objc public enum JXIAPManagerCode: Int { - ///未知错误 - case unknown - ///取消交易 - case cancelled - ///没有商品 - case noProduct +public extension JXIAPManagerDelegate { + + func jx_iapPaySuccess(productId: String, receipt: String, transactionIdentifier: String) {} + func jx_iapPayFailed(productId: String, code: JXIAPManager.ErrorCode, msg: String?) {} + func iapPayRestore(productIds: [String], transactionIds: [String]) {} } + public class JXIAPManager: NSObject { + public enum ErrorCode { + ///未知错误 + case unknown + ///取消交易 + case cancelled + ///没有商品 + case noProduct + } + public static let manager: JXIAPManager = JXIAPManager() @@ -91,7 +91,7 @@ extension JXIAPManager: SKProductsRequestDelegate { DispatchQueue.main.async { if let productId = self.productId { self.productId = nil - self.delegate?.jx_iapPayFailed?(productId: productId, code: .noProduct, msg: nil) + self.delegate?.jx_iapPayFailed(productId: productId, code: .noProduct, msg: nil) } } return @@ -155,7 +155,7 @@ extension JXIAPManager { guard let productId = self.productId, productId == transaction.payment.productIdentifier else { return } self.productId = nil - self.delegate?.jx_iapPaySuccess?(productId: productId, receipt: encodeStr, transactionIdentifier: transactionIdentifier) + self.delegate?.jx_iapPaySuccess(productId: productId, receipt: encodeStr, transactionIdentifier: transactionIdentifier) } @@ -166,9 +166,9 @@ extension JXIAPManager { switch error?.code { case SKError.paymentCancelled: - self.delegate?.jx_iapPayFailed?(productId: productId, code: .cancelled, msg: error?.localizedDescription) + self.delegate?.jx_iapPayFailed(productId: productId, code: .cancelled, msg: error?.localizedDescription) default: - self.delegate?.jx_iapPayFailed?(productId: productId, code: .unknown, msg: error?.localizedDescription) + self.delegate?.jx_iapPayFailed(productId: productId, code: .unknown, msg: error?.localizedDescription) } }