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
650
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
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
420
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
4
1.1k
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
130
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
1.6k
Storybook との上手な向き合い方を考える
re_taro
5
2.2k
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
150
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
A Tour of Anti-patterns for Functional Programming
guvalif
0
300
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
120
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
670
Featured
See All Featured
Being A Developer After 40
akosma
87
590k
Designing the Hi-DPI Web
ddemaree
280
34k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Navigating Team Friction
lara
183
14k
GitHub's CSS Performance
jonrohan
1030
460k
Thoughts on Productivity
jonyablonski
67
4.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Six Lessons from altMBA
skipperchong
27
3.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
Large-scale JavaScript Application Architecture
addyosmani
510
110k
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