12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- //
- // KMPurchaseManager.swift
- // PDF Master
- //
- // Created by lizhe on 2023/6/1.
- //
- import Cocoa
-
- #if VERSION_DMG
- #endif
- typealias KMPurchaseCompletion = (_ isSuccess: Bool, _ error: String) -> Void
- typealias KMPurchaseFetchProductCompletion = (_ isSuccess: Bool, _ products: Array<Any>, _ error: String?) -> Void
- class KMPurchaseManager: NSObject {
- public static let manager = KMPurchaseManager()
- var availableProducts: [KMProduct] = []
-
- override init() {
- super.init()
-
- // self.fetchProducts { isSuccess, products, error in
- // if isSuccess {
- // print("获取产品成功")
- // } else {
- // print("获取产品失败")
- // }
- // print(products)
- // }
- }
-
- func fetchProducts(completeion: @escaping KMPurchaseFetchProductCompletion) {
- print("获取产品中")
- #if VERSION_FREE
- print("正在获取产品中AppStore")
- KMInAppPurchaseManager.manager.fetchProducts(completion: completeion)
- #endif
-
- #if VERSION_DMG
- print("正在获取产品中DMG")
- KMDMGPurchaseManager.manager.fetchProducts(completion: completeion)
- #endif
- }
-
- func purchaseProduct(productIdentifier: String, completion: @escaping KMPurchaseCompletion) {
- print("准备订阅中")
- #if VERSION_FREE
- print("正在订阅中AppStore")
- KMInAppPurchaseManager.manager.purchaseProduct(productIdentifier: productIdentifier, completion: completion)
- #endif
-
- #if VERSION_DMG
- print("正在订阅中DMG")
- KMDMGPurchaseManager.manager.purchaseProduct(productIdentifier: productIdentifier, completion: completion)
- #endif
- }
- }
|