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

App内課金におけるトラブルを劇的に減らすための取り組み

Koki Hirokawa
September 02, 2023

 App内課金におけるトラブルを劇的に減らすための取り組み

iOSDC Japan 2023にて発表

Koki Hirokawa

September 02, 2023

Transcript

56 slides
  1. AbemaTV, Inc. All Rights Reserved AbemaTV, Inc. All Rights Reserved

    1 2 September 2023 Koki Hirokawa App಺՝ۚʹ͓͚Δ τϥϒϧΛ ܶతʹݮΒͨ͢ΊͷऔΓ૊Έ
  2. AbemaTV, Inc. All Rights Reserved Koki Hirokawa • 2020೥ AbemaTV

    ৽ଔೖࣾ • ࠓظͷਪ͠υϥϚʮϋϠϒαফ๷ஂʯ 2 Profile @pihero13 KokiHirokawa
  3. AbemaTV, Inc. All Rights Reserved 3 1. App಺՝ۚ 2. ൃੜͨ͠τϥϒϧ

    3. ABEMAίΠϯͷߪೖॲཧ 4. ରࡦ 5. ·ͱΊ ໨࣍
  4. AbemaTV, Inc. All Rights Reserved App಺՝ۚͷछྨ 6 • ফ໣ܕ ◦

    Ұ౓͚ͩ࢖༻ՄೳͰɺ࠶౓࢖༻͢Δʹ͸৽ͨʹߪೖ͢Δඞཁ͕͋Δ ◦ αʔϏε಺௨՟ • ඇফ໣ܕ ◦ Ұ౓͚ͩߪೖ͢Ε͹ɺݮΔ͜ͱͳ͘ແظݶʹ࢖༻Մೳͳ੡඼ ◦ ޿ࠂͷඇදࣔػೳ • ࣗಈߋ৽αϒεΫϦϓγϣϯ ◦ ॴఆͷظؒதɺਵ࣌ߋ৽͞ΕΔίϯςϯπΛߪೖͰ͖Δ੡඼ɻϢʔβ͕ղ໿͠ͳ͍ݶΓࣗಈత ʹߋ৽͞ΕΔ ◦ ಈը΍Իָͷ഑৴ • ඇߋ৽αϒεΫϦϓγϣϯ ◦ ظؒݶఆͷαʔϏε΍ίϯςϯπ΁ͷΞΫηεݖΛߪೖͰ͖Δɻࣗಈߋ৽͸͞Εͳ͍ ◦ ήʔϜ಺ίϯςϯπͷγʔζϯύε
  5. AbemaTV, Inc. All Rights Reserved ABEMAͷApp಺՝ۚ - ࣗಈߋ৽αϒεΫϦϓγϣϯ 7 •

    ABEMAϓϨϛΞϜ ◦ ϓϨϛΞϜձһݶఆͷػೳΛఏڙ͢Δ ▪ ϓϨϛΞϜର৅࡞඼͕ݟ์୊ ▪ ޿ࠂͳ͠Ͱݟಀ͠ࢹௌ͕Ͱ͖Δ ▪ ݟಀ͠഑৴Ͱίϝϯτ͕ݟΒΕΔ ▪ ์ૹதͰ΋࠷ॳ͔ΒݟΒΕΔ ▪ μ΢ϯϩʔυ࠶ੜ ◦ 1ϲ݄͝ͱʹࣗಈߋ৽͞ΕΔ
  6. AbemaTV, Inc. All Rights Reserved ABEMAͷApp಺՝ۚ - ফ໣ܕ 8 •

    LiveEvent PPV ◦ νέοτΛߪೖ͢Δ͜ͱͰ LiveEvent ͕ ࢹௌͰ͖Δ ◦ ABEMAϓϨϛΞϜݶఆͷׂҾ
  7. AbemaTV, Inc. All Rights Reserved ABEMAͷApp಺՝ۚ - ফ໣ܕ 9 •

    ABEMAίΠϯ ◦ ABEMAͷαʔϏε಺௨՟ ▪ TVODʢഇࢭʣ ΍ PPV ͷߪೖ ▪ ౤͛મʢഇࢭʣ • ※ 2023೥6݄15೔ʹഇࢭ ◦ ABEMAίΠϯΛհ͞ͳ͍ɺPPV ͷ ௚઀ߪೖ͕Մೳʹ
  8. AbemaTV, Inc. All Rights Reserved StoreKit 10 • App಺՝ۚΛ࣮૷͢ΔͨΊʹඞཁͳϑϨʔϜϫʔΫ ◦

    ͦͷଞɺΞϓϦͷϨϏϡʔͳͲ App Store ͱͷ࿈ܞΛαϙʔτ͢Δ • Original API ͱ StoreKit 2 ◦ Original API ▪ StoreKit 2 ͕ొ৔͢ΔલͷɺैདྷͷAPI ▪ iOS 3.0+ ◦ StoreKit 2 ▪ WWDC 2021 Ͱൃද͞Εͨ৽نAPIͰɺSwift Concurrency Λ࠾༻ͨ͠Ϟμϯͳ I/F ▪ iOS15.0+
  9. AbemaTV, Inc. All Rights Reserved StoreKit 11 • App಺՝ۚΛ࣮૷͢ΔͨΊʹඞཁͳϑϨʔϜϫʔΫ ◦

    ͦͷଞɺΞϓϦͷϨϏϡʔͳͲ App Store ͱͷ࿈ܞΛαϙʔτ͢Δ • Original API ͱ StoreKit 2 ◦ Original APIʢར༻தʣ ▪ StoreKit 2 ͕ొ৔͢ΔલͷɺैདྷͷAPI ▪ iOS 3.0+ ◦ StoreKit 2 ▪ WWDC 2021 Ͱൃද͞Εͨ৽نAPIͰɺSwift Concurrency Λ࠾༻ͨ͠Ϟμϯͳ I/F ▪ iOS15.0+
  10. AbemaTV, Inc. All Rights Reserved ABEMAίΠϯͷ͓࿩ 13 • ABEMAͷαʔϏε಺௨՟ ◦

    PPV ΍ TVOD ͷߪೖʹར༻ • ফ໣ܕ՝ۚ ◦ 1౓࢖༻͢Δͱফ໣͞ΕΔ ◦ Կ౓Ͱ΋ߪೖ
  11. AbemaTV, Inc. All Rights Reserved 14 1000 ίΠϯʢ1200 ԁʣΛߪೖͨ͠ɻ ͔͠͠ɺApple

    ͔Β͸ 2000 ίΠϯ෼ʢ2400 ԁʣͷ੥ٻ ͕དྷ͍ͯΔɻ 1000 ίΠϯ෼ʢ1200 ԁʣΛฦۚͯ͠ཉ͍͠ɻ Ϣʔβ͔Βͷ໰͍߹Θͤ 1000 ίΠϯ Expected 1000 ίΠϯ × 2 Actual ABEMAίΠϯͷॏෳߪೖ
  12. AbemaTV, Inc. All Rights Reserved 15 1000 ίΠϯʢ1200 ԁʣΛߪೖͨ͠ɻ ͔͠͠ɺApple

    ͔Β͸ 2000 ίΠϯ෼ʢ2400 ԁʣͷ੥ٻ ͕དྷ͍ͯΔɻ 1000 ίΠϯ෼ʢ1200 ԁʣΛฦۚͯ͠ཉ͍͠ɻ Ϣʔβ͔Βͷ໰͍߹Θͤ 1000 ίΠϯ Expected 1000 ίΠϯ × 2 Actual ҙਤͤͣ2ճߪೖ͞Εͯ͠·͏τϥϒϧ͕ൃੜ ‛ ABEMAίΠϯͷॏෳߪೖ
  13. AbemaTV, Inc. All Rights Reserved ABEMAίΠϯͷߪೖϑϩʔ 19 (※) verifyReceipt ͸ݱࡏdeprecated

    ( https://developer.apple.com/documentation/appstorereceipts/verifyreceipt )
  14. AbemaTV, Inc. All Rights Reserved τϥϯβΫγϣϯΛऴྃ͢ΔλΠϛϯά 21 (※1) https://developer.apple.com/documentation/storekit/skpaymentqueue/1506003-finishtransaction •

    ΞϓϦ͔Β໌ࣔతʹऴྃͤ͞Δ • ABEMAίΠϯߪೖͷτϥϯβΫγϣϯ͸ɺABEMAͷαʔόʹͯϢʔβ΁ͷίΠϯ෇༩Λߦͬ ͨͷͪʹ SQPaymentQueue.finishTransaction(_:) Λݺͼग़͢͜ͱͰऴྃͤ͞Δ ◦ > After you finish a transaction, don’t take any actions on it or do any work to deliver the product. If any work remains, your app isn’t ready to finish the transaction. (※1) • Ϣʔβ΁ͷ੥ٻͷΈߦΘΕɺίΠϯ͕෇༩͞Εͳ͍ঢ়ଶΛ๷͙ • ফ໣ܕ͸Կ౓Ͱ΋ߪೖͰ͖ɺաڈʹߪೖͨ͜͠ͱ͕͋Δ঎඼Λ࠶౓ߪೖͨ͠৔߹ɺϨγʔτͷ ߪೖཤྺ্͕ॻ͖͞ΕΔɻաڈͷߪೖཤྺΛࢀরͰ͖ͳ͘ͳΔՄೳੑ͕͋ΔͨΊ஫ҙ͕ඞཁ
  15. AbemaTV, Inc. All Rights Reserved ະ׬ྃτϥϯβΫγϣϯ - Apple΁ͷߪೖϦΫΤετ 24 •

    ϑΝϛϦʔڞ༗ͷঝೝ଴ͪ ◦ ঝೝͱߪೖͷϦΫΤετͷઃఆ͕͞Ε͍ͯΔ৔߹ɺϑΝϛϦʔڞ༗ͷ؅ཧऀ͕ঝೝ ͢Δ·Ͱ͸ߪೖ͕อཹͱͳΔ ◦ ※ ঝೝ͞ΕΔ·Ͱ੥ٻ͸͞Εͳ͍ • SQPaymentQueue.finishTransaction(_:) ͷΤϥʔ ◦ Apple ͔ΒΤϥʔʢ SKPaymentTransactionState.failed ʣ͕ฦ͖ͬͯͨ৔߹ʹݺͼ ग़͕ͨ͠ɺࣦഊͨ͠ͱ͖ ◦ Throwing function ʹ͸ͳ͍ͬͯͳ͍ͷͰ஫ҙ ◦ > In rare circumstances, this call might fail, and you'll receive updates for that transaction again. (※1) (※1) https://developer.apple.com/documentation/storekit/skpaymentqueue/1506026-transactions
  16. AbemaTV, Inc. All Rights Reserved ະ׬ྃτϥϯβΫγϣϯ - τϥϯβΫγϣϯͷऴྃ 28 •

    SQPaymentQueue.finishTransaction(_:) ͷΤϥʔ ◦ Throwing function ʹ͸ͳ͍ͬͯͳ͍ͷͰ஫ҙ ◦ > In rare circumstances, this call might fail, and you'll receive updates for that transaction again. (※1) (※1) https://developer.apple.com/documentation/storekit/skpaymentqueue/1506026-transactions
  17. AbemaTV, Inc. All Rights Reserved ະ׬ྃτϥϯβΫγϣϯͷϋϯυϦϯά 29 • ಛఆͷλΠϛϯάͰະ׬ྃτϥϯβΫγϣϯΛ֬ೝ͠ɺߪೖॲཧΛϦτϥΠ ◦

    ΞϓϦىಈ࣌ ◦ όοΫάϥ΢ϯυ͔ΒϑΥΞάϥ΢ϯυʹͳͬͨ࣌ ◦ ίΠϯ࢒ߴදࣔ࣌ • Ϣʔβ͕ίΠϯ࢒ߴΛ֬ೝ͢ΔલʹϦτϥΠ͠ɺෆ੔߹ͳঢ়ଶΛૣ͘ղফ͢ΔΑ͏ʹͨ͠ • ະ׬ྃτϥϯβΫγϣϯ͸ SKPaymentQueue.transactions Ͱऔಘ
  18. AbemaTV, Inc. All Rights Reserved 33 1000 ίΠϯʢ1200 ԁʣΛߪೖͨ͠ɻ ͔͠͠ɺApple

    ͔Β͸ 2000 ίΠϯ෼ʢ2400 ԁʣͷ੥ٻ ͕དྷ͍ͯΔɻ 1000 ίΠϯ෼ʢ1200 ԁʣΛฦۚͯ͠ཉ͍͠ɻ Ϣʔβ͔Βͷ໰͍߹Θͤ 1000 ίΠϯ Expected 1000 ίΠϯ × 2 Actual ໰୊ͷ੔ཧ
  19. AbemaTV, Inc. All Rights Reserved ௐࠪ 35 • ࠶ݱ֬ೝ ◦

    ߪೖϦτϥΠͱͳΔ֤έʔεͷڍಈ֬ೝ ◦ ߪೖϘλϯͷ࿈ଧ ◦ ະ׬ྃτϥϯβΫγϣϯ͕͋Δঢ়ଶͰͷߪೖϘλϯԡԼ ◦ ߪೖதͷΞϓϦΩϧ ◦ … • ࠶ݱ֬ೝࣗମΛऔΔ͜ͱ͕ࠔ೉ͩͬͨ
  20. AbemaTV, Inc. All Rights Reserved ϩάૹ৴ 36 • Ϣʔβ͕ߪೖϘλϯΛԡԼ͔ͯ͠Βߪೖॲཧ͕ऴྃ͢Δ·ͰͷϓϩηεΛϩάͱͯ͠ه࿥ •

    ϢʔβId, ը໘Id, ঎඼Id, ߪೖϓϩηεId, σόΠεId, ೔࣌ͳͲ ABEMA App GTM ߦಈϩάج൫ BigQuery
  21. AbemaTV, Inc. All Rights Reserved ϩάૹ৴ - ߪೖϓϩηε 37 •

    ߪೖϓϩηε͝ͱʹIdʢจࣈྻʣ Λ෇༩ ◦ ※ ϦτϥΠ࣌͸֤Idͷ಄ʹ retryΛ෇༩͢Δ͜ͱͰɺ৽ن ߪೖͱ۠ผ
  22. AbemaTV, Inc. All Rights Reserved ΫϥΠΞϯτϩάͷௐࠪ 39 • ͓໰͍߹Θ͕ͤ͋ͬͨϢʔβ͸ɺίΠϯߪೖͷϦτϥΠॲཧΛߦ͍ͬͯͨ ◦

    prefix͕retryͷߪೖϓϩηεIdΛ֬ೝ ◦ ϦτϥΠॲཧࣗମ͸໰୊ͳ͘ߦΘΕ͍ͯΔΑ͏ͩͬͨ • 2ճ໨ͷߪೖॲཧ͸ϢʔβʹΑͬͯ։࢝͞Ε͍ͯͨ ◦ Ϣʔβ͕ߪೖϘλϯΛԡԼͨ͜͠ͱΛද͢ߪೖϓϩηεID͕֬ೝͰ͖ͨ ◦ ߪೖϘλϯͷ࿈ଧରࡦ΍ɺߪೖॲཧதͷը໘ϩοΫ͸ߦ͍ͬͯͨ
  23. AbemaTV, Inc. All Rights Reserved ΫϥΠΞϯτϩάͷௐࠪ 40 • ϦτϥΠʹΑͬͯίΠϯ͕෇༩͞Εͨʹ΋ؔΘΒ ͣɺϢʔβ͸࠶౓ߪೖϘλϯΛԡ͍ͯͨ͠(?)

    • ίΠϯ࢒ߴ͕ߋ৽͞Ε͍ͯͳ͍(?) • Ϣʔβ͸ίΠϯ࢒ߴ͕ߋ৽͞Εͨ͜ͱʹؾ͍ͮͯ ͍ͳ͍ͷͰ͸(?)
  24. AbemaTV, Inc. All Rights Reserved طଘ࣮૷ͷ໰୊఺Λ୳Δ 41 • طଘͷ࣮૷Ͱ͸ɺϢʔβ͕ίΠϯ࢒ߴΛ֬ೝ͢ΔલͷಛఆλΠϛϯάʹ͓͍ͯɺ҉໧తʹϦ τϥΠॲཧΛ࣮ߦ͠ɺϢʔβͷෆ੔߹ʢ=ίΠϯ࢒ߴͷߋ৽ʣΛ͍ͪૣ͘ղফ͢Δ͜ͱΛ໨

    ࢦ͍ͯͨ͠ • ߪೖ͕ࣦഊͨ͠ࡍʹɺϢʔβ͸࠶౓ߪೖϘλϯΛԡ͢͜ͱͰෆ੔߹Λղফ͠Α͏ͱ͢ΔͷͰ ͸ͳ͍͔ ◦ ߪೖ࣌ʹະ׬ྃτϥϯβΫγϣϯ͕͋Δ৔߹͸ΤϥʔͱͳΔ͕ɺίΠϯߪೖը໘ʹભ Ҡ͢ΔલʹϦτϥΠॲཧ͕׬ྃ͠ɺίΠϯ࢒ߴ͕ߋ৽͞Ε͍ͯΔ͜ͱʹؾ͔ͮͣɺͦͷ ··ߪೖϘλϯΛԡͯ͠͠·͏(?)
  25. AbemaTV, Inc. All Rights Reserved 42 • ىಈγʔέϯεऴྃޙʹະ׬ྃτϥϯβΫγϣϯͷ༗ແΛ֬ೝ͠ɺߪೖ్தͷίΠϯ͕͋Δ ͜ͱΛΞϥʔτදࣔͰ఻͑ΔΑ͏ʹͨ͠ ◦

    όοΫάϥ΢ϯυ͔ΒϑΥΞάϥ΢ϯυʹͳͬͨͱ͖, ίΠϯ࢒ߴΛදࣔ͢Δ৔߹΋ • Before ◦ ίΠϯ࢒ߴͷෆ੔߹Λ͍ͪૣ͘ղফ͢Δ • After ◦ ίΠϯ࢒ߴͷෆ੔߹Λ͍ͪૣ͘ೝࣝͯ͠΋Β͏ վળ఺ᶃ - ߪೖ్தͷίΠϯͷଘࡏΛ͍ͪૣ͘఻͑Δ
  26. AbemaTV, Inc. All Rights Reserved ΞϓϦىಈ௚ޙ͔ΒτϥϯβΫγϣϯͷߋ৽Λ؂ࢹ 45 • After ◦

    ΞϓϦىಈ௚ޙ UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:) ʹ SKPaymentTransactionObserver.paymentQueue(_:updatedTransactions:) Λར༻͠ ͯະ׬ྃτϥϯβΫγϣϯΛड͚औΔʢ؂ࢹ͢ΔʣΑ͏ʹͨ͠ ◦ Appleਪ঑ (※1) • Before ◦ ΞϓϦىಈɾόοΫϑΥΞɾίΠϯ࢒ߴදࣔ࣌ʹ SQPaymentQueue.transactions Λར ༻ͯ͠ະ׬ྃτϥϯβΫγϣϯΛड͚औΔ ▪ > The value of this property is undefined when there are no observers attached to the payment queue. (※2) (※1) https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/setting_up_the_transaction_observer_for_the_payment_queue (※2) https://developer.apple.com/documentation/storekit/skpaymentqueue/1506026-transactions
  27. AbemaTV, Inc. All Rights Reserved • ϦτϥΠॲཧ׬ྃ࣌ʹɺ੒ޭ·ͨ͸ࣦഊͷεφοΫόʔΛ දࣔ ◦ Ϣʔβ͸ίΠϯ࢒ߴ͕දࣔ͞ΕΔը໘ʹભҠͤͣͱ

    ΋ɺଈ࠲ʹ݁ՌΛड͚औΔ͜ͱ͕Ͱ͖Δ ◦ εφοΫόʔ ▪ Ϣʔβͷը໘ૢ࡞Λ્֐͢Δ͜ͱͳ͘ԿΒ͔ͷ ৘ใΛ఻͑Δࡍʹར༻͢Δڞ௨ίϯϙʔωϯτ ▪ ը໘Լ෦ʹදࣔ͞ΕɺҰఆ࣌ؒͰࣗಈతʹඇද ࣔͱͳΔ վળ఺ᶄ - ϦτϥΠॲཧ׬ྃͷεφοΫόʔදࣔ 52

More Decks by Koki Hirokawa

Other Decks in Technology