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
670
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
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
なぜCodeceptJSを選んだか
goataka
0
160
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
1
110
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
260
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
170
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
210
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
190
ハイテク休憩
sat
PRO
2
140
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
250
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
1
240
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
530
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
190
Featured
See All Featured
Producing Creativity
orderedlist
PRO
341
39k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
We Have a Design System, Now What?
morganepeng
51
7.3k
Gamification - CAS2011
davidbonilla
80
5.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
How to Ace a Technical Interview
jacobian
276
23k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Mobile First: as difficult as doing things right
swwweet
222
9k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
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