Pro Yearly is on sale from $80 to $50! »

運用から学ぶPlay Billing Library

934a9e49edc3174d09ab2e09daed5062?s=47 ymnder
April 10, 2019

運用から学ぶPlay Billing Library

In-tamachi Billing Night, 2019/04/10 20:00-20:10
https://billing-night.connpass.com/event/125510/

934a9e49edc3174d09ab2e09daed5062?s=128

ymnder

April 10, 2019
Tweet

Transcript

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

  2. whoami twitter:@ymnd, github:@ymnder Application Engineer Android Android [ -02] Nikkei

    Development Book VOL 2 [ -08] hifumi https://riconken.bitbucket.io/hifumi/ 2
  3. Otemachi.swift#3 iOS App by ikai https://nikkei.connpass.com/event/123343/ 3

  4. Today s menu 4

  5. None
  6. : Google Play Billing Library Google Play Store In-app Billing

    API wrap 6
  7. : startConnection isReady querySkuDetailsAsync 7

  8. : startConnection querySkuDetailsAsync launchBilling ow PurchasesUpdatedListener 8

  9. : 9 SFNPUF MPDBM SFQPTJUPSZ VTFDBTF QSFTFOUFS WJFX

  10. : Remote Local Repository interface RxJava Single Completable Remote BillingClient

    DroidKaigi 2019 10
  11. Repository 11 class PlayBillingRepositoryImpl @Inject constructor( private val remote: RemotePlayBilling

    ) : PlayBillingRepository { override fun startSubscription(activity: Activity, skuId: String): Observable<PurchaseResponse> { 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<PurchasesUpdatedResponse>(…) } return@flatMap Observable.just(it) } //… } } } } }
  12. Repository 12 class PlayBillingRepositoryImpl @Inject constructor( private val remote: RemotePlayBilling

    ) : PlayBillingRepository { override fun startSubscription(activity: Activity, skuId: String): Observable<PurchaseResponse> { 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<PurchasesUpdatedResponse>(…) } return@flatMap Observable.just(it) } //… } } } } }
  13. 13 billing.startSubscription(this@BillingActivity, skuId) .subscribe({ //ߪೖॲཧ͕੒ޭͨ͠ }, { //ߪೖॲཧ͕ࣦഊͨ͠ Toast.makeText(this@BillingActivity, it.message,

    Toast.LENGTH_SHORT).show() })
  14. :BillingActivity Activity 14

  15. : 15

  16. None
  17. BillingClient BillingClient 17

  18. 18

  19. 19

  20. BillingClient API queryPurchaseHistoryAsync 20

  21. queryPurchaseHistoryAsync ID 1 21

  22. 22

  23. BillingClient API Purchases.subscriptions API 23

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

    24
  25. Nikkei Development Book VOL 2 Android / iOS ✕ /

    [ -02] https://techbookfest.org/event/tbf06/circle/40320001 25
  26. Subscription :)

  27. 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