Closed Tonyhe666 closed 1 year ago
Apple allows you to promote in-app purchases for sale directly on the App Store. This allows users to purchase your products from the App Store itself, rather than from within your app.
The requirement for supporting this feature is that your app must include a class that implements SKPaymentTransactionObserver
, and the paymentQueue(_:updatedTransactions:)
and paymentQueue(_:shouldAddStorePayment:for:)
delegate methods. If you don't include these requirements then you'll get an error when you attempt to submit the app to the App Store and you have existing IAP promotions.
However, StoreKit2
doesn't include any of these: they're old-style StoreKit1
things.
StoreHelper
has a solution to this potentially messy situation. It includes a class that handles all the requirements and tells the StoreKit2
-based code when a direct App Store purchase is made. See comments in the readme (Direct purchases of App Store Promotions).
// Sent when a user initiates an IAP buy from the App Store @available(iOS 11.0, *) optional func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool
在Storekit2中如何处理?