Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOSDC 20190906: 動画アプリの投げ銭機能における
消耗型課金の仕組みと実装

D390d62a9772cf2e0bd8000157abbff8?s=47 Takeshi Ihara
September 06, 2019

iOSDC 20190906: 動画アプリの投げ銭機能における
消耗型課金の仕組みと実装

D390d62a9772cf2e0bd8000157abbff8?s=128

Takeshi Ihara

September 06, 2019
Tweet

More Decks by Takeshi Ihara

Other Decks in Programming

Transcript

  1. ಈըΞϓϦͷ౤͛મػೳʹ͓͚Δ
 ফ໣ܕ՝ۚͷ࢓૊Έͱ࣮૷ 2019/09/06 iOSDC 2019 Takeshi Ihara

  2. Takeshi Ihara • 2018.09.01 AbemaTV Join • 2018.09.02 iOSDC 2018

    LT ʮখ͘͞͸͡ΊΔ୺຤؅ཧʯ • ϘϧμϦϯάͱ֨ಆήʔϜ͕झຯ • https://twitter.com/nonchalant0303
  3. αϙʔτػೳ (AbemaTV) • 2019.04.22
 αϙʔτػೳΛ
 ϦϦʔεʂ
 ൪૊΍൪૊ग़ԋऀʹ ελϯϓΛૹͬͯ
 αϙʔτ͕Ͱ͖Δʂ

  4. None
  5. αϙʔτ͢Δͧʂ

  6. 1. App಺՝ۚ 2. ՝ۚܗࣜʹΑΔҧ͍ 3. AbemaTVʹ͓͚Δফ໣ܕ՝ۚͷઃܭ 4. AbemaTVʹ͓͚Δফ໣ܕ՝ۚͷಈ࡞ݕূ 5. ·ͱΊ

  7. App಺՝ۚ

  8. App಺՝ۚͱ͸ • App ಺՝ۚͱ͸ɺiOS σόΠε΍ίϯϐϡʔλ্ͷ 
 App ͷதͰ௥Ճͷίϯςϯπ΍ఆظߪಡίϯςϯπΛ
 ߪೖͰ͖Δ࢓૊Έ https://support.apple.com/ja-jp/HT202023

  9. ՝ۚܗࣜ • ফ໣ܕ (Consumable) - ΞϓϦ಺௨՟ͳͲ Ұ౓࢖͏ͱͳ͘ͳΓɺ࠶ߪೖ͢Δ͜ͱ͕Ͱ͖Δ
 • ඇফ໣ܕ (Non-Consumable)

    - ޿ࠂͷඇදࣔͳͲ Ұ౓ͷߪೖ͚ͩͰແ੍ݶʹ࢖༻Ͱ͖Δ • ࣗಈߋ৽αϒεΫϦϓγϣϯ (Auto-Renewable Subscriptions) - ֹ݄VODͳͲ ݄ؒαʔϏε΍ఆظతʹΞοϓσʔτ͞ΕͨίϯςϯπΛߪೖ͢Δ͜ͱ͕Ͱ͖Δ • ඇߋ৽αϒεΫϦϓγϣϯ (Non-Renewing Subscriptions) - γʔζϯύεͳͲ ظؒݶఆͷαʔϏε΍ίϯςϯπΛߪೖ͢Δ͜ͱ͕Ͱ͖Δ
  10. AbemaTVʹ͓͚Δࣗಈߋ৽αϒεΫϦγϣϯ • ¥960/݄ͰϓϨϛΞϜػೳΛఏڙ 1. ͢΂ͯͷ࡞඼͕ݟ์୊ 2. ޿ࠂͳ͠ͰϏσΦΛ͙͢࠶ੜ 3. ์ૹதͰ΋࠷ॳ͔ΒΈΒΕΔ 4.

    μ΢ϯϩʔυͰ௨৴ྔΛ΄΅θϩʹ 5. ์ૹޙͷ൪૊Ͱ΋ίϝϯτָ͕͠ΊΔ
  11. AbemaTVʹ͓͚Δফ໣ܕ՝ۚ • ΞϓϦ಺௨՟(AbemaίΠϯ) ίΠϯͰελϯϓΛߪೖͯ͠ɺ
 ൪૊΍൪૊ग़ԋऀʹελϯϓΛૹͬͯ
 αϙʔτ͕Ͱ͖Δʂ

  12. ՝ۚܗࣜʹΑΔҧ͍

  13. ՝ۚܗࣜʹΑΔػೳͷҧ͍ ࠶ߪೖͷՄ൱ Ϩγʔτ΁ͷදࣔ σόΠεؒͰͷಉ ظ ෮ݩ ফ໣ܕ ˓
 Կ౓Ͱ΋ ࠶ߪೖ·Ͱ

    ಉظͳ͠ ෮ݩ͞Εͳ͍ ඇফ໣ܕ ✖ ৗʹ γεςϜʹΑΓಉ ظ γεςϜʹΑΓಉ ظ ࣗಈߋ৽
 αϒεΫϦϓγϣ ϯ ✖
 ࣗಈతʹߋ৽͞Ε Δ ৗʹ γεςϜʹΑΓಉ ظ γεςϜʹΑΓಉ ظ ඇߋ৽αϒεΫϦ ϓγϣϯ ˓ ߋ৽͢Δ ৗʹ "QQʹΑΓಉظ "QQʹΑΓಉظ https://developer.apple.com/jp/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Products.html#//apple_ref/doc/uid/TP40008267-CH2-SW2 https://developer.apple.com/jp/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html#//apple_ref/doc/uid/TP40008267-CH8-SW9
  14. ՝ۚܗࣜʹΑΔػೳͷҧ͍ ࠶ߪೖͷՄ൱ Ϩγʔτ΁ͷදࣔ σόΠεؒͰͷಉ ظ ෮ݩ ফ໣ܕ ˓
 Կ౓Ͱ΋ ࠶ߪೖ·Ͱ

    ಉظͳ͠ ෮ݩ͞Εͳ͍ ඇফ໣ܕ ✖ ৗʹ γεςϜʹΑΓಉ ظ γεςϜʹΑΓಉ ظ ࣗಈߋ৽
 αϒεΫϦϓγϣ ϯ ✖
 ࣗಈతʹߋ৽͞Ε Δ ৗʹ γεςϜʹΑΓಉ ظ γεςϜʹΑΓಉ ظ ඇߋ৽αϒεΫϦ ϓγϣϯ ˓ ߋ৽͢Δ ৗʹ "QQʹΑΓಉظ "QQʹΑΓಉظ https://developer.apple.com/jp/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Products.html#//apple_ref/doc/uid/TP40008267-CH2-SW2 https://developer.apple.com/jp/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html#//apple_ref/doc/uid/TP40008267-CH8-SW9
  15. ࠶ߪೖ͕Կ౓Ͱ΋ग़དྷΔ • ϩʔΧϧͷϨγʔτͷߪೖཤྺ্͕ॻ͖͞ΕΔ ߪೖʹԠͨ͡ΠϯηϯςΟϒΛϢʔβʔʹ෇༩Ͱ͖ͳ͘ͳΔ
 AppStoreʹΑΔ՝ۚॲཧ͸׬͍ྃͯ͠Δ → ՝͚ۚͩൃੜͯ͠ϢʔβʔʹΠϯηϯςΟϒΛ
 ෇༩͍ͯ͠ͳ͍ঢ়ଶ

  16. { "receipt": { …, "in_app": [ { "product_id": “com.nonchalant.consumable1”, "transaction_id":

    "1000000551439498", "purchase_date": "2019-09-01 00:00:00 Etc/GMT”, … } ] } } Ϩγʔτ (ॳճߪೖ࣌) https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1
  17. { "receipt": { …, "in_app": [ { "product_id": “com.nonchalant.consumable1", "transaction_id":

    "1000000556349963", "purchase_date": "2019-09-03 10:10:26 Etc/GMT”, … } ] } } Ϩγʔτ (࠶ߪೖ࣌) https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1
  18. ࠶ߪೖ͕ग़དྷΔ৚݅ • ಉ͡঎඼ͷ՝ۚτϥϯβΫγϣϯ͕ऴ͍ྃͯ͠Δ ՝ۚτϥϯβΫγϣϯ → SKPaymentTransaction τϥϯβΫγϣϯ͕ऴ͍ྃͯ͠Δ → SKPaymentQueue.finishTransaction(_:)

  19. ՝ۚτϥϯβΫγϣϯͷѻ͍ͷ஫ҙ఺ • ΠϯηϯςΟϒΛ෇༩͢Δ·ͰτϥϯβΫγϣϯΛऴྃͯ͠͸͍͚ͳ͍ > Once you’ve delivered the product, your

    application must call finishTransaction: to complete the transaction. When you call finishTransaction:, the transaction is removed from the payment queue. To ensure that products are not lost, your application should deliver the product before calling finishTransaction:. • ߪೖཤྺ͕Ϩγʔτʹৗʹදࣔ͞ΕΔ՝ۚܗࣜͰ͸
 ҙࣝ͠ͳͯ͘΋໰୊ͳ͍ ඇফ໣ܕɺࣗಈߋ৽αϒεΫϦϓγϣϯɺඇߋ৽αϒεΫϦϓγϣϯ https://www.rapid-ideas.com/previews/wsa/page9/files/StoreKitGuide.pdf
  20. AbemaTVʹ͓͚Δ
 ফ໣ܕ՝ۚͷઃܭ

  21. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  22. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  23. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  24. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  25. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  26. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  27. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  28. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  29. ফ໣ܕ՝ۚͷߪೖϑϩʔ 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 3. Ϩγʔτૹ৴ 2. ߪೖ׬ྃ
  30. ՝ۚ׬ྃޙʹࣦഊ͢Δέʔε 1 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App

    Store AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 3. Ϩγʔτૹ৴ 2. ߪೖ׬ྃ
  31. Ϩγʔτૹ৴ʹࣦഊ͢Δέʔε • ωοτϫʔΫͳͲͷ໰୊Ͱ
 APIϦΫΤετͷ։࢝ʹࣦഊ͢Δέʔε • AppStoreʹΑΔ՝ۚ͸ൃੜ͍ͯ͠Δ • αʔόʔଆͰAbemaίΠϯ෇༩͕ग़དྷ͍ͯͳ͍ • ՝ۚτϥϯβΫγϣϯ͸ऴ͍ྃͯ͠ͳ͍

    Ϣʔβʔ͕࠶ߪೖͰ͖ͳ͍
  32. ՝ۚ׬ྃޙʹࣦഊ͢Δέʔε 2 4. ϨγʔτݕূϦΫΤετ 5. Ϩγʔτݕূ݁Ռ 6. AbemaίΠϯ
 ෇༩ App

    Store AbemaTV iOS AbemaTV Server 7. ׬ྃϨεϙϯε (201) 1. ߪೖϦΫΤετ
 (τϥϯβΫγϣϯͷ։࢝) 8. τϥϯβΫγϣϯ
 ͷऴྃ 2. ߪೖ׬ྃ 3. Ϩγʔτૹ৴
  33. ׬ྃϨεϙϯεʹࣦഊ͢Δέʔε • ΞϓϦͷΫϥογϡͳͲͰ
 APIϨεϙϯεͷड৴ʹࣦഊ͢Δέʔε • AppStoreʹΑΔ՝ۚ͸ൃੜ͍ͯ͠Δ • αʔόʔଆͰAbemaίΠϯ෇༩͕׬͍ྃͯ͠ΔՄೳੑ͕͋Δ • ՝ۚτϥϯβΫγϣϯ͸ऴ͍ྃͯ͠ͳ͍

    Ϣʔβʔ͕࠶ߪೖͰ͖ͳ͍
  34. ະ׬ྃτϥϯβΫγϣϯͷ ϦτϥΠ͕ඞཁ

  35. AbemaίΠϯະ෇༩ͷϦτϥΠ 3. ϨγʔτݕূϦΫΤετ 4. Ϩγʔτݕূ݁Ռ 5. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 6. ׬ྃϨεϙϯε (201) 7. τϥϯβΫγϣϯ
 ͷऴྃ 2. Ϩγʔτૹ৴ 1. ະ׬ྃτϥϯβΫγϣϯͷऔಘ
 (SKPaymentQueue.transactions)
  36. AbemaίΠϯະ෇༩ͷϦτϥΠ 3. ϨγʔτݕূϦΫΤετ 4. Ϩγʔτݕূ݁Ռ 5. AbemaίΠϯ
 ෇༩ App Store

    AbemaTV iOS AbemaTV Server 6. ׬ྃϨεϙϯε (201) 7. τϥϯβΫγϣϯ
 ͷऴྃ 2. Ϩγʔτૹ৴ 1. ະ׬ྃτϥϯβΫγϣϯͷऔಘ
 (SKPaymentQueue.transactions)
  37. AbemaίΠϯ෇༩ࡁΈͷϦτϥΠ 3. ϨγʔτݕূϦΫΤετ 4. Ϩγʔτݕূ݁Ռ App Store AbemaTV iOS AbemaTV

    Server 5. AbemaίΠϯ෇༩ࡁΈΤϥʔ (409) 6. τϥϯβΫγϣϯ
 ͷऴྃ 2. Ϩγʔτૹ৴ 1. ະ׬ྃτϥϯβΫγϣϯͷऔಘ
 (SKPaymentQueue.transactions)
  38. AbemaίΠϯ෇༩ࡁΈͷϦτϥΠ 3. ϨγʔτݕূϦΫΤετ 4. Ϩγʔτݕূ݁Ռ App Store AbemaTV iOS AbemaTV

    Server 5. AbemaίΠϯ෇༩ࡁΈΤϥʔ (409) 6. τϥϯβΫγϣϯ
 ͷऴྃ 2. Ϩγʔτૹ৴ 1. ະ׬ྃτϥϯβΫγϣϯͷऔಘ
 (SKPaymentQueue.transactions)
  39. AbemaίΠϯ෇༩ࡁΈͷϦτϥΠ 3. ϨγʔτݕূϦΫΤετ 4. Ϩγʔτݕূ݁Ռ App Store AbemaTV iOS AbemaTV

    Server 5. AbemaίΠϯ෇༩ࡁΈΤϥʔ (409) 6. τϥϯβΫγϣϯ
 ͷऴྃ 2. Ϩγʔτૹ৴ 1. ະ׬ྃτϥϯβΫγϣϯͷऔಘ
 (SKPaymentQueue.transactions)
  40. τϥϯβΫγϣϯ͕
 ऴ͍ྃͯ͠Δ → AbemaίΠϯ͕
 ෇༩͞Ε͍ͯΔ

  41. ϦτϥΠॲཧͷݺͿλΠϛϯά • ىಈ࣌ɺόοΫϑΥΞ࣌ɺίΠϯ࢒ߴදࣔ࣌ʹ
 ϦτϥΠॲཧΛߦ͏ Ϣʔβʔ͕ίΠϯ࢒ߴΛ֬ೝ͢ΔલʹϦτϥΠ͢ΔΑ͏ʹͯ͠ɺ
 ෆ੔߹ʹؾ෇͔ͤͮΒ͍ͤͯ͘͞Δ

  42. ϦτϥΠॲཧͷ஫ҙ఺ • ະ׬ྃτϥϯβΫγϣϯ͸SKPaymentQueue.transactionsͰ औಘͰ͖Δ ߪೖதͷτϥϯβΫγϣϯ΋ؚ·ΕΔ
 • ਖ਼ৗͳߪೖϑϩʔͷࡍ͸ϦτϥΠॲཧ
 ΛߦΘͳ͍ͳͲͷॲཧ͕ඞཁ

  43. AbemaTVʹ͓͚Δ
 ফ໣ܕ՝ۚͷ
 ಈ࡞ݕূ

  44. ݕূ߲໨ͷೝࣝ߹Θͤ • ߪೖϑϩʔ͕τϥϯβΫγϣϯͳͲͷ಺෦ͷঢ়ଶʹґଘͯ͠ ͍ΔͷͰɺQAνʔϜʹγʔέϯεਤΛ౉ͯ͠΋
 ݕূ߲໨Λ࡞੒͢Δͷ͕೉͍͠ • ࣮ࡍʹͲͷΑ͏ͳঢ়گͰͲͷΑ͏ͳૢ࡞Λ͢Ε͹ɺͲͷΑ͏ ͳঢ়ଶʹͳΔ͔ͷೝࣝ߹ΘͤΛ͠ͳ͍ͱ
 ݕূ߲໨Λ࡞੒Ͱ͖ͳ͍

  45. Mind Meister • ϚΠϯυϚοϓ࡞੒πʔϧͷMind MeisterΛ༻͍ͯ
 ೝࣝ߹ΘͤΛ͠·ͨ͠ https://www.mindmeister.com/1309256136?t=X6wMB2GxG6

  46. ίΠϯपΓͷදࣔܥ

  47. ίΠϯपΓͷදࣔܥ

  48. ੒ޭ͢Δߪೖϑϩʔ

  49. ࣦഊ͢Δߪೖϑϩʔ

  50. ߪೖϑϩʔͷಈ࡞ݕূ • ফ໣ܕ՝ۚͷߪೖϑϩʔΛ࣮૷ͨ͠αϯϓϧϓϩδΣΫτ https://github.com/Nonchalant/Consumable - Consumable In-App Purchase - Combine

    - SwiftUI
  51. None
  52. ·ͱΊ

  53. ·ͱΊ • ফ໣ܕ՝ۚ͸ΠϯηϯςΟϒΛ෇༩͢Δ·Ͱ
 τϥϯβΫγϣϯΛऴྃ͠ͳ͍ ࠶ߪೖ͢Δͱߪೖཤྺ্͕ॻ͖͞ΕΔͨΊ • ߪೖϑϩʔͰࣦഊ͢Δ͜ͱ͕͋ΔͷͰϦτϥΠػߏ͕ඞཁ ਖ਼ৗͳߪೖಋઢ্ͰϦτϥΠ͠ͳ͍

  54. Thank you