$30 off During Our Annual Pro Sale. View Details »

運用から学ぶPlay Billing Library

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/

ymnder

April 10, 2019
Tweet

More Decks by ymnder

Other Decks in Programming

Transcript

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

    View Slide

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

    View Slide

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

    View Slide

  4. Today s menu
    4

    View Slide

  5. View Slide

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

    View Slide

  7. :
    startConnection isReady
    querySkuDetailsAsync
    7

    View Slide

  8. :
    startConnection
    querySkuDetailsAsync
    launchBilling ow
    PurchasesUpdatedListener
    8

    View Slide

  9. :
    9
    SFNPUF MPDBM
    SFQPTJUPSZ
    VTFDBTF
    QSFTFOUFS
    WJFX

    View Slide

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

    View Slide

  11. 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)
    }
    //…
    }
    }
    }
    }
    }

    View Slide

  12. 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)
    }
    //…
    }
    }
    }
    }
    }

    View Slide

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

    View Slide

  14. :BillingActivity
    Activity
    14

    View Slide

  15. :
    15

    View Slide

  16. View Slide

  17. BillingClient
    BillingClient
    17

    View Slide

  18. 18

    View Slide

  19. 19

    View Slide

  20. BillingClient
    API
    queryPurchaseHistoryAsync
    20

    View Slide

  21. queryPurchaseHistoryAsync
    ID 1
    21

    View Slide

  22. 22

    View Slide

  23. BillingClient
    API
    Purchases.subscriptions API
    23

    View Slide

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

    View Slide

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

    View Slide

  26. Subscription :)

    View Slide

  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

    View Slide