Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Promoting IAP対応から学ぶ外部アプリ内課金実装 / Promoting IAP a...

uzzu
April 10, 2019

Promoting IAP対応から学ぶ外部アプリ内課金実装 / Promoting IAP and others

In-tamachi Billing Night 登壇資料
https://billing-night.connpass.com/event/125510/

uzzu

April 10, 2019
Tweet

More Decks by uzzu

Other Decks in Technology

Transcript

  1. About me @uzzu (GitHub, Twtter, etc…)
 Cookpad Inc.
 ユーザ・決済基盤部 エンジニア


    
 アプリ内課金とは
 前職(スマホゲーム開発)からの
 お付き合い(iOS/Android)
 
 https://uzzu.co
  2. Promoting IAPに対応するには •まずはアプリ内課金実装をする •protocol SKPaymentTransactionObserverの
 optional func paymentQueue(_ queue: SKPaymentQueue,


    shouldAddStorePayment: SKPayment,
 for: SKProduct) -> Bool
 を実装する •AppStore ConnectでPromoting IAP用の商品設定をする •(任意) SKProductPromotionControllerで表示制御をする ※正確な情報はApp内課金プログラミングガイドを参照してね
  3. shouldAddStorePayment public func paymentQueue( _ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment,

    for product: SKProduct) -> Bool { return true // PaymentQueueʹੵ·ΕΔ } 最短実装。だがしかし…
  4. どうする? // shouldAddStorePaymentͷύϥϝʔλΛ࣋ͭstructΛ༻ҙ public struct PromotingPurchasePayment { public var product:

    SKProduct public var payment: SKPayment init(payment: SKPayment, product: SKProduct) { assert(payment.productIdentifier == product.productIdentifier) self.payment = payment self.product = product } } // Promoting IAPͷ৘ใΛஷΊΔprotocol public protocol PromotingPurchasePaymentHolder { func add(_ storePayment: StorePayment) func pendingPayments() -> [StorePayment] func consume(_ storePayment: StorePayment) }
  5. どうする? let holder: PromotingPurchasePaymentHolder public func paymentQueue( _ queue: SKPaymentQueue,

    shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool { // ͱΓ͋͑ͣஷΊΔ!! holder.add( StorePayment(payment: payment, product: product) ) return false }