Slide 1

Slide 1 text

Play Billing Library In-tamachi Billing Night, 2019/04/10 20:00-20:10

Slide 2

Slide 2 text

whoami twitter:@ymnd, github:@ymnder Application Engineer Android Android [ -02] Nikkei Development Book VOL 2 [ -08] hifumi https://riconken.bitbucket.io/hifumi/ 2

Slide 3

Slide 3 text

Otemachi.swift#3 iOS App by ikai https://nikkei.connpass.com/event/123343/ 3

Slide 4

Slide 4 text

Today s menu 4

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

: Google Play Billing Library Google Play Store In-app Billing API wrap 6

Slide 7

Slide 7 text

: startConnection isReady querySkuDetailsAsync 7

Slide 8

Slide 8 text

: startConnection querySkuDetailsAsync launchBilling ow PurchasesUpdatedListener 8

Slide 9

Slide 9 text

: 9 SFNPUF MPDBM SFQPTJUPSZ VTFDBTF QSFTFOUFS WJFX

Slide 10

Slide 10 text

: Remote Local Repository interface RxJava Single Completable Remote BillingClient DroidKaigi 2019 10

Slide 11

Slide 11 text

Repository 11 class PlayBillingRepositoryImpl @Inject constructor( private val remote: RemotePlayBilling ) : PlayBillingRepository { override fun startSubscription(activity: Activity, skuId: String): Observable { return remote.connect() .flatMapObservable { remote.querySkuDetailsAsync(skuId).flatMapObservable { response -> remote.launchBillingFlow(activity, response.skuDetailsList.first()) .flatMapObservable { remote.observePurchasesUpdated() .flatMap { if (it.result != BillingClient.BillingResponse.OK) { return@flatMap Observable.error(…) } return@flatMap Observable.just(it) } //… } } } } }

Slide 12

Slide 12 text

Repository 12 class PlayBillingRepositoryImpl @Inject constructor( private val remote: RemotePlayBilling ) : PlayBillingRepository { override fun startSubscription(activity: Activity, skuId: String): Observable { return remote.connect() .flatMapObservable { remote.querySkuDetailsAsync(skuId).flatMapObservable { response -> remote.launchBillingFlow(activity, response.skuDetailsList.first()) .flatMapObservable { remote.observePurchasesUpdated() .flatMap { if (it.result != BillingClient.BillingResponse.OK) { return@flatMap Observable.error(…) } return@flatMap Observable.just(it) } //… } } } } }

Slide 13

Slide 13 text

13 billing.startSubscription(this@BillingActivity, skuId) .subscribe({ //ߪೖॲཧ͕੒ޭͨ͠ }, { //ߪೖॲཧ͕ࣦഊͨ͠ Toast.makeText(this@BillingActivity, it.message, Toast.LENGTH_SHORT).show() })

Slide 14

Slide 14 text

:BillingActivity Activity 14

Slide 15

Slide 15 text

: 15

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

BillingClient BillingClient 17

Slide 18

Slide 18 text

18

Slide 19

Slide 19 text

19

Slide 20

Slide 20 text

BillingClient API queryPurchaseHistoryAsync 20

Slide 21

Slide 21 text

queryPurchaseHistoryAsync ID 1 21

Slide 22

Slide 22 text

22

Slide 23

Slide 23 text

BillingClient API Purchases.subscriptions API 23

Slide 24

Slide 24 text

Google Play Billing Library Purchases.subscriptions API Real-time developer noti cations 24

Slide 25

Slide 25 text

Nikkei Development Book VOL 2 Android / iOS ✕ / [ -02] https://techbookfest.org/event/tbf06/circle/40320001 25

Slide 26

Slide 26 text

Subscription :)

Slide 27

Slide 27 text

https://speakerdeck.com/ymnder/xiang-jie-ding-qi-gou-ru What's new in Google Play Billing v1.0 -> v1.1 https://speakerdeck.com/ymnder/whats-new-in-google-play-billing What's new in Google Play Billing v1.2 v1.1 -> v1.2 https://speakerdeck.com/ymnder/whats-new-in-google-play-billing-v1-dot-2 27