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

2d855b951ff3160c55915821261432f9?s=47 uzzu
April 10, 2019

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

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

2d855b951ff3160c55915821261432f9?s=128

uzzu

April 10, 2019
Tweet

Transcript

  1. 2.

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


    
 アプリ内課金とは
 前職(スマホゲーム開発)からの
 お付き合い(iOS/Android)
 
 https://uzzu.co
  2. 8.

    Promoting IAPに対応するには •まずはアプリ内課金実装をする •protocol SKPaymentTransactionObserverの
 optional func paymentQueue(_ queue: SKPaymentQueue,


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

    shouldAddStorePayment public func paymentQueue( _ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment,

    for product: SKProduct) -> Bool { return true // PaymentQueueʹੵ·ΕΔ } 最短実装。だがしかし…
  4. 12.

    どうする? // 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. 13.

    どうする? let holder: PromotingPurchasePaymentHolder public func paymentQueue( _ queue: SKPaymentQueue,

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