Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Promoting IAP対応から学ぶ外部アプリ内課金実装 / Promoting IAP and others
Search
uzzu
April 10, 2019
Technology
2
1.1k
Promoting IAP対応から学ぶ外部アプリ内課金実装 / Promoting IAP and others
In-tamachi Billing Night 登壇資料
https://billing-night.connpass.com/event/125510/
uzzu
April 10, 2019
Tweet
Share
More Decks by uzzu
See All by uzzu
Context Receiversに思いを馳せる / Context Receivers
uzzu
0
480
StoreKitのこれまでとこれから / StoreKit 2 from 1
uzzu
5
7.8k
Autofill Framework
uzzu
0
63
アプリ内課金の最新事情 クライアントサイド編 / In-app Purchase in Cookpad 2019
uzzu
3
4.1k
Billing Client 2.0 acknowledgement
uzzu
0
15k
ブログ作り直した / My blog @ Othlo Tech
uzzu
0
100
新規アプリ開発を支えるユーザ・決済基盤
uzzu
2
2.3k
kotlin-mpp-library-tips
uzzu
1
6k
Coroutine Kyuin
uzzu
2
240
Other Decks in Technology
See All in Technology
AMLD 2024 - Build Your Own GPT
donlelef
1
260
8週連続ウェビナー_イチから学ぶFivetran
cmsuzu
0
170
こんなに簡単!AWSマルチアカウント
takuya_terada
0
120
サービス成長と共に肥大化するモノレポ、長くなるCI時間 / As services grow, monorepos get bigger and CI time gets longer
kohbis
5
2.1k
技術広報として2023年度に頑張ったこと / What we did well in FY2023 as a DevRel
pauli
5
490
Autopsy of a Cascading Outage from a MySQL Crashing Bug
jfg956
0
200
家族アルバム みてねで直面してきた技術的負債 / MIXI KAG 2024
isaoshimizu
17
7.7k
Vos logs méritent mieux que la config par défaut
lyrixx
2
410
中央集権体制からDataOpsへの転換 / centralized-to-dataops-transformation
pei0804
7
1.6k
#51 “Empowering Azure Storage with RDMA”
cafenero_777
3
220
KubeCon EU: Unlocking new Platform Experiences with Open Interfaces
salaboy
1
380
初心者が行く!サーバレスWebアプリ開発の道
nagaharutogawa
0
450
Featured
See All Featured
It's Worth the Effort
3n
180
27k
Faster Mobile Websites
deanohume
296
30k
Done Done
chrislema
178
15k
Rebuilding a faster, lazier Slack
samanthasiow
72
8.2k
The Art of Programming - Codeland 2020
erikaheidi
40
12k
Typedesign – Prime Four
hannesfritz
36
2k
BBQ
matthewcrist
78
8.7k
Why Our Code Smells
bkeepers
PRO
330
56k
The Illustrated Children's Guide to Kubernetes
chrisshort
28
46k
How GitHub Uses GitHub to Build GitHub
holman
467
290k
The Language of Interfaces
destraynor
150
23k
Making the Leap to Tech Lead
cromwellryan
123
8.4k
Transcript
Promoting IAP対応から学ぶ 外部アプリ内課金実装 @uzzu
About me @uzzu (GitHub, Twtter, etc…) Cookpad Inc. ユーザ・決済基盤部 エンジニア
アプリ内課金とは 前職(スマホゲーム開発)からの お付き合い(iOS/Android) https://uzzu.co
https://speakerdeck.com/uzzu/xin-gui-apurikai-fa-wozhi-eruyuzajue-ji-ji-pan
はとりあえず置いといて、Promoting IAPについて説明します 外部アプリ内課金実装?????
Promoting IAPとは •App Storeアプリから アプリ内課金アイテムの購入を 実施する為の機能
Promoting IAPとは
Promoting IAPとは 未インストールユーザも利用できる
Promoting IAPに対応するには •まずはアプリ内課金実装をする •protocol SKPaymentTransactionObserverの optional func paymentQueue(_ queue: SKPaymentQueue,
shouldAddStorePayment: SKPayment, for: SKProduct) -> Bool を実装する •AppStore ConnectでPromoting IAP用の商品設定をする •(任意) SKProductPromotionControllerで表示制御をする ※正確な情報はApp内課金プログラミングガイドを参照してね
テスト itms-services:// ?action=purchaseIntent &bundleId={Bundle Identifier} &productIdentifier={Product Identifier} ※正確な情報はApp内課金プログラミングガイドを参照してね
shouldAddStorePayment public func paymentQueue( _ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment,
for product: SKProduct) -> Bool { return true // PaymentQueueʹੵ·ΕΔ } 最短実装。だがしかし…
俺たちには利用規約がある •return trueとしてしまうと、アプリ遷移後にすぐに IAP決済処理が走ってしまう (正確にはSKPaymentQueue#add後、任意のタイミング) •利用規約に同意してもらうタイミングがない アプリ内課金商品によっては年齢確認も必要 •利用規約がなくても、アプリの初期化処理はしばしある その後に処理するようにしないといけない
どうする? // 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) }
どうする? let holder: PromotingPurchasePaymentHolder public func paymentQueue( _ queue: SKPaymentQueue,
shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool { // ͱΓ͋͑ͣஷΊΔ!! holder.add( StorePayment(payment: payment, product: product) ) return false }
どうする? •アプリ初期化後、トップ画面の ViewController上で 未処理のPromoting IAPがあれば 決済処理開始 •クックパッドでは トップ画面とは別の UIViewControllerに遷移して処理している •決済処理が終わったらHolderから破棄
Promoting IAPまとめ •超カジュアル実装ならtrue •アプリ初期化処理や利用規約があるならfalse •個人プロダクトでないアプリであれば だいたいfalseになるんじゃないか? •貯めて特定画面で処理が柔軟
Promoting IAPだけが 特別?
アプリ外に決済起点のある アプリ内課金機能は 他にもある (実際に決済が走っているかはさておき)
例えば •Promotion Code(iOS, Android) •Google Play Points(Android)
一旦貯めるのは柔軟 •iOSの場合はこれまでにお話した通り •Google Play(Android)においては特に貯めずとも BillingClient#queryPurchases を 特定画面で呼び出して購入状況を確認すれば良い iOSと違い決済は既に走っているので 決済後の処理(いわゆる復元処理)をやれば良さそう
まとめ •アプリ外部からのトリガーによるアプリ内課金を処理する前に (時には)サービス利用規約への同意が必要(利用規約の更新もあるよね) その後に 都度課金であれば(時には)年齢確認が必要 定期購読であれば定期購読サービス利用規約の同意が必要 •どのケースにおいても プラットフォームからの通知は貯めておいて 特定画面(アプリ起動後のTOP画面等)でまとめて処理すると 柔軟で良い
(Realtime notificationが使えるなら使いたいが未検証)
終 ありがとうございました