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
680
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.8k
バーチャル背景を実現しよう
aratayokoyama
0
710
アクセシブルなチャートを実現しよう
aratayokoyama
0
1.5k
TwilioのCameraSource に任意のフレームを使用するすゝめ
aratayokoyama
0
1.5k
VirtualBitriseUserGroupMeetup_fresh_bob
aratayokoyama
0
110
Other Decks in Technology
See All in Technology
商品レコメンドでのexplicit negative feedbackの活用
alpicola
1
340
あなたの知らないクラフトビールの世界
miura55
0
120
#TRG24 / David Cuartielles / Post Open Source
tarugoconf
0
570
完全自律型AIエージェントとAgentic Workflow〜ワークフロー構築という現実解
pharma_x_tech
0
330
実践! ソフトウェアエンジニアリングの価値の計測 ── Effort、Output、Outcome、Impact
nomuson
0
2k
Godot Engineについて調べてみた
unsoluble_sugar
0
370
re:Invent2024 KeynoteのAmazon Q Developer考察
yusukeshimizu
1
130
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
150
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
6
54k
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
1.1k
The future we create with our own MVV
matsukurou
0
2k
GeometryReaderやスクロールを用いた表現と紐解き方
fumiyasac0921
0
100
Featured
See All Featured
The Invisible Side of Design
smashingmag
299
50k
We Have a Design System, Now What?
morganepeng
51
7.3k
Docker and Python
trallard
43
3.2k
Optimising Largest Contentful Paint
csswizardry
33
3k
Unsuck your backbone
ammeep
669
57k
Thoughts on Productivity
jonyablonski
68
4.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Fireside Chat
paigeccino
34
3.1k
Building an army of robots
kneath
302
45k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
500
Scaling GitHub
holman
459
140k
How to Ace a Technical Interview
jacobian
276
23k
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