Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
StoreKitTestを使ってアプリ内課金のテストや検証を効率化する方法
Search
BOB
September 02, 2023
Technology
2
640
StoreKitTestを使ってアプリ内課金のテストや検証を効率化する方法
iOSDC2023
https://fortee.jp/iosdc-japan-2023/proposal/338c5361-c647-4b24-ac00-fa712ee702c8
BOB
September 02, 2023
Tweet
Share
More Decks by BOB
See All by BOB
既存サブスクリプション商品にアップグレード・ダウングレード商品を追加しよう
aratayokoyama
1
1.7k
バーチャル背景を実現しよう
aratayokoyama
0
690
アクセシブルなチャートを実現しよう
aratayokoyama
0
1.5k
TwilioのCameraSource に任意のフレームを使用するすゝめ
aratayokoyama
0
1.5k
VirtualBitriseUserGroupMeetup_fresh_bob
aratayokoyama
0
110
Other Decks in Technology
See All in Technology
SSMRunbook作成の勘所_20241120
koichiotomo
2
130
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
310
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
160
AIチャットボット開発への生成AI活用
ryomrt
0
170
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
190
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
170
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
120
Featured
See All Featured
Happy Clients
brianwarren
98
6.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Adopting Sorbet at Scale
ufuk
73
9.1k
Code Review Best Practice
trishagee
64
17k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
The Pragmatic Product Professional
lauravandoore
31
6.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Done Done
chrislema
181
16k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Transcript
StoreKitTestΛͬͯΞϓϦ ՝ۚͷςετݕূΛޮ Խ͢Δํ๏ 2023/09/02 Arata Yokoyama GitHub : ARATAYOKOYAMA X
: BOBG1018Vi
About Me • ԣࢁ৽ • 2020αΠόʔΤʔδΣϯτ৽ଔೖࣾ • λοϓϧͷiOSΤϯδχΞ • ւಓग़
2
ؔ࿈ηογϣϯ StoreKit2Λͬͨ՝ۚγεςϜͷϑϧϦχϡʔΞϧ • 2023/09/03 11:00ʙTrack B • https://fortee.jp/iosdc-japan-2023/proposal/38b684f3-86a6-43be-8d27-48d9710626bf طଘαϒεΫϦϓγϣϯʹΞοϓάϨʔυɾμϯάϨʔυΛՃ͠Α ͏
• https://fortee.jp/iosdc-japan-2022/proposal/ 466c7cea-375f-427e-9fe1-73e651693615 3
StoreKitTestͱ 4
StoreKitTestͱ • WWDC2020Ͱൃද͞Εͨ՝ۚςετ༻ͷϑϨʔϜϫʔΫͰ͢ • ࠷େͷಛɼAppStoreConnectΛհͣ͞ʹಈ࡞͢Δ͜ͱͰ͢ • ಈ࡞ʹStoreKit configurationΛ༻͠·͢ • ಈ࡞ཁ݅iOS14.0Ҏ্Ͱ͢
• ػೳΛϑϧ׆༻͠Α͏ͱ͢Δͱɼ14.2Ҏ্͕ඞཁͰ͢ • ࣮ػɼγϛϡϨʔλʔΛΘͣಈ࡞͠·͢ 5
Sandboxͱͷҧ͍ 6
Sandboxͱͷҧ͍ πʔϧ App Store Connectͷઃఆ͕ඞཁ App StoreʹΑͬͯ ॺ໊͞ΕͨAppϨγʔτΛ ఏڙ Ϣʔβʔͷٻ͕ൃੜ
XcodeͷStoreKitςετ × ×(XcodeʹΑΔॺ໊) × Sandbox ◦ ◦ × TestFlightʢSandboxΛ ༻ʣ ◦ ◦ × • StoreKitTestAppStoreConnectʹ࣮ࡍͷΛ࡞͢Δඞཁ͕ͳ͍ • ੜ͞ΕΔϨγʔτٴͼɼTransactionμϛʔͰ͋Δ • ςετ࣮ࡍͷڍಈʹ͍ͭͯޙ΄Ͳ 7
StoreKit configurationͷಋೖํ๏ 8
σϞΞϓϦ iOSDC2023-StoreKitTestDEMO • Xcode14.3.1/iOS16.4 • StoreKit2, StoreKit configuration, StoreKitTestΛ࠾༻ •
https://github.com/ARATAYOKOYAMA/iOSDC2023- StoreKitTestDEMO 9
σϞΞϓϦ 10 View Presenter PurchaseService MeService - ࣗͷใΛऔಘ͢Δ - ߪೖ͢Δ
- ෮ݩ͢Δ - ֤αʔϏεʹࢦࣔΛग़͢ - ݁ՌΛViewʹөͤ͞Δ
ConfigurationΛ࡞ ಋೖํ๏(1/8) 1. Xcode͔ΒFile > New > FileΛબͯ͠ɼStoreKitͱೖྗ 2. StoreKit
Configuration FileΛબ͠ɼ໊લΛೖྗͯ͠อଘ *ࠓճSync this file with an app in App Store ConnectͷνΣοΫೖΕͳ͍ *νΣοΫΛೖΕͨ߹ɼAppStoreConnectͱಉظͤ͞Δ͜ͱ͕Ͱ͖·͢ 11
࡞ͨ͠ConfigurationΛ֬ೝ ಋೖํ๏(2/8) 12
ࣗಈߋ৽αϒεΫϦϓγϣϯΛ࡞ ಋೖํ๏(3/8) • ֤छྨ͝ͱʹApp՝ۚΛ࡞Ͱ͖·͢ *ࠓճࣗಈߋ৽αϒεΫϦϓγϣϯͰઆ໌͠·͢ 13
αϒεΫϦϓγϣϯάϧʔϓ໊Λೖྗ ಋೖํ๏(4/8) 14
໊ͱIDΛೖྗ ಋೖํ๏(5/8) 15
ͨ͠ConfigurationΛ֬ೝ ಋೖํ๏(6/8) ࡞ͨ͠ Ձ֨ ΦϑΝʔྨ ϩʔΧϥΠζ 16
StoreKitTest༻ূ໌ॻͷൃߦ ಋೖํ๏(7/8) 17
ൃߦͨ͠ূ໌ॻͷ֬ೝ ಋೖํ๏(8/8) 18
StoreKit configurationΛ༻͢Δ 19
StoreKit configurationΛ༻͢Δ 20
ҙɿΦϦδφϧͷStoreKit • XcodeʹΑͬͯॺ໊͞ΕͨϨγʔτ͕ൃߦ͞ΕΔͨΊɼదʹϋϯυϦϯά͢Δඞཁ͕͋Γ·͢ • λοϓϧͰɼςετத͔Ͳ͏͔Ͱฦ٫͢ΔϨγʔτΛมߋ͍ͯ͠·͢ 21
ҙɿStoreKit2 iOS16Ҏ্͔ͭStoreKit2Ͱ͋Εɼtransactionʹؚ·ΕΔAppStore.Environment ͕༻ՄೳͰ͢ 22
֤छΦϑΝʔ 23
͓ࢼ͠ΦϑΝʔ • ͍ɼલ͍ɼແྉͱຊ൪ͱಉ༷ʹઃఆՄೳͰ͢ • Ձ֨ظؒҙͷΛઃఆͰ͖·͢ 24
ϓϩϞʔγϣϯΦϑΝʔ • ͓ࢼ͠ΦϑΝʔͱಉ༷ʹࢧ͍ํ๏ͳͲॊೈʹઃఆՄೳͰ͢ • ຊ൪ͱҟͳΓ1ʹ30Ҏ্ͷϓϩϞʔγϣϯΦϑΝʔΛઃఆͯ͠ͳͦ͞͏Ͱͨ͠ 25
ϓϩϞʔγϣϯΦϑΝʔ • Editor > Subscription Offers Key ͔ΒKeyIDͱsignature͕Θ͔Γ·͢ • nonceదͳUUIDɼtimestampదͳͰ͋Γ·ͤΜ
26
ΦϑΝʔίʔυ • ΦϑΝʔίʔυಉ༷ʹՁ֨ઃఆͰ͖·͢ • ର͓ࢼ͠ΦϑΝʔͱͷ༏ઌॱҐઃఆͰ͖·͢ • Reference Name͕ͦͷ··ίʔυͱͳΓɼೖྗ͞Εͨঢ়ଶͰಈ࡞͠·͢ 27
ࣦഊɾฦۚΛ࠶ݱ͢Δ 28
ܾࡁࣦഊΛ࠶ݱ͢Δ • Ұ෦ͷέʔε͚ͩͰ͕͢ɼڧ੍తʹΤϥʔΛൃੜͤ͞Δ͜ͱ͕Ͱ͖·͢ • ͜ΕΒͷέʔε͕ͦͷ··StoreKitTestͰѻ͑ΔΤϥʔͰ͢ छྨ ֓ཁ SKErrorUnknown ෆ໌·ͨ༧ظ͠ͳ͍Τϥʔ͕ൃੜ͠ ͨ͜ͱΛࣔ͢
SKErrorInvalidOfferIde ntifier ΦϑΝʔ ID ͕ແޮͰ͋Δ͜ͱΛࣔ͢ SKErrorInvalidOfferIde ntifier ࢧׂ͍Ҿͷॺ໊͕ແޮͰ͋Δ͜ͱΛ ࣔ͢ SKErrorMissingOfferPa rams ࢧׂ͍Ҿʹύϥϝʔλʔ͕ܽམ͍ͯ͠ Δ͜ͱΛࣔ͢ SKErrorInvalidOfferPric e App Store Connect Ͱࢦఆͨ͠Ձ͕֨ແޮ Ͱ͋Δ͜ͱΛࣔ͢ 29
ܾࡁࣦഊσϞ 30
ܾࡁࣦഊσϞ 31
ฦۚΛ࠶ݱ͢Δ ҙͷ༗ޮͳτϥϯβΫγϣϯΛબͯ͠ Refund PurchaseΛબ͢Δ 32
StoreKitTestΛ༻͍ͯUnitTestΛॻ͘ 33
ڞ௨ॲཧ Testதʹ༻͢ΔConfigurationΛಡΈࠐΉ 34
ڞ௨ॲཧ disableDialogs ܾࡁ࣌ʹදࣔ͞ΕΔμΠΞϩάදࣔ ΛແޮԽ͢Δ 35
ڞ௨ॲཧ clearTransactions τϥϯβΫγϣϯΛۭʹ͢Δ 36
ڞ௨ॲཧ failTransactionsEnabled ܾࡁΛඞͣޭͤ͞Δ 37
ڞ௨ॲཧ timeRate αϒεΫϦϓγϣϯͷߋ৽ස oneRenewalEveryTwoSecondsશ ͯͷظ͕ؒ1ճ/2ඵؒ 38
ڞ௨ॲཧ τϥϯβΫγϣϯΛۭʹ͢Δ 39
ޭ ಛผͳ͜ͱͤͣɼςετΛॻ͍ͯOK 40
ࣦഊ failTransactionsEnabled = true ܾࡁΛඞࣦͣഊͤ͞Δ failureError = .unknown ࣦഊཧ༝ 41
෮ݩ buyProduct SKTestSessionʹؚ·ΕΔؔ ΞϓϦ֎͔Βߪೖͨ͠ͳͲͷςετʹ ཱͪ·͢ 42
transaction.updatesͷࢹ ྃ͢ΔTaskͰͳ͍ͷͰɼઃఆͨ͠ timeRateʹରԠ͢ΔܗͰsleepΛೖΕ Δ 43
Grace Period billingGracePeriodIsEnabled billing RetryͱGracePeriodΛ༗ޮԽ shouldEnterBillingRetryOnRenewal αϒεΫϦϓγϣϯͷߋ৽࣌ʹಥೖͤ͞Δ forceRenewalOfSubscription ҙͷαϒεΫϦϓγϣϯΛڧ੍తʹ ߋ৽͢Δ
44
UnitTestҎ֎ͷ͓͢͢Ίར༻γʔϯ 45
StoreKit2ͷஔ͖͑αϙʔτ • ϢχοτςετͪΖΜɼτϥϯβΫγϣϯͷڍಈΛҰͭͮͭ֬ೝͰ͖Δ ͜ͱڧྗͳαϙʔτ • verifyReceiptͷΤϯυϙΠϯτ͕Deprecatedʹͳͬͨ͜ͱΛड͚ͯɼຊ֨త ʹStoreKit2ͷҠߦΛݕ౼͢ΔϑΣʔζʹདྷͨͱࢥΘΕ·͢ • https://buy.itunes.apple.com/verifyReceipt •
طʹλοϓϧStoreKit2ͷҠߦΛ͓ྃͯ͠Γɼͦͷ༰ͪ͜Βͷηο γϣϯͰͥͻޚཡ͍ͩ͘͞ • 09/03 11:00ʙTrack B StoreKit2Λͬͨ՝ۚγεςϜͷϑϧϦχϡʔΞϧ 46
MVPͷ։ൃϋοΧιϯͳͲ • αʔόଆͷ։ൃΛͨͣͯ͠ɼ՝ۚϩδοΫͷ࣮ΛਐΊΒΕΔ • ϋοΧιϯͳͲຊ൪ఆͰͳ͍։ൃʹ͓͍ͯɼඞཁ࠷ݶͷߏͰσϞ Λ࣮ݱͰ͖Δ 47
Flutter • XcodeٴͼiOSͷػೳͰ͋ΔͨΊɼFlutter։ൃʹ͓͍ͯಉ༷ͷԸܙΛड͚Δ ͜ͱ͕Ͱ͖·͢ 48
ࢀߟจݙ • https://developer.apple.com/jp/documentation/storekit/in-app_purchase/ testing_at_all_stages_of_development_with_xcode_and_sandbox/ • https://developer.apple.com/documentation/xcode/setting-up-storekit-testing- in-xcode • https://developer.apple.com/documentation/storekit/appstore/environment •
https://developer.apple.com/documentation/appstorereceipts/verifyreceipt
StoreKitTestΛͬͯΞϓϦ ՝ۚͷςετݕূΛޮ Խ͢Δํ๏ 2023/09/02 Arata Yokoyama GitHub : ARATAYOKOYAMA X
: BOBG1018Vi