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
720
アクセシブルなチャートを実現しよう
aratayokoyama
0
1.5k
TwilioのCameraSource に任意のフレームを使用するすゝめ
aratayokoyama
0
1.5k
VirtualBitriseUserGroupMeetup_fresh_bob
aratayokoyama
0
110
Other Decks in Technology
See All in Technology
信頼性を支えるテレメトリーパイプラインの構築 / Building Telemetry Pipeline with OpenTelemetry
ymotongpoo
9
3.6k
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
270
Site Reliability Engineering on Kubernetes
nwiizo
6
3.2k
実践!生成AIのビジネス活用 / How to utilize Generative AI in your own business
gakumura
1
170
第27回クラウド女子会 ~re:Invent 振り返りLT会~ 私の周辺で反響のあった re:Invent 2024 アップデートつれづれ/reinvent-2024-update-reverberated-around-me
emiki
1
530
AIアプリケーション開発でAzure AI Searchを使いこなすためには
isidaitc
1
220
Microsoft Ignite 2024 最新情報!Microsoft 365 Agents SDK 概要 / Microsoft Ignite 2024 latest news Microsoft 365 Agents SDK overview
karamem0
0
160
ハンズオンで学ぶ Databricks - Databricksにおけるデータエンジニアリング
taka_aki
1
2k
SIEMによるセキュリティログの可視化と分析を通じた信頼性向上プロセスと実践
coconala_engineer
1
2k
アクセシブルなマークアップの上に成り立つユーザーファーストなドロップダウンメニューの実装 / 20250127_cloudsign_User1st_FE
bengo4com
1
1.1k
2024AWSで個人的にアツかったアップデート
nagisa53
1
120
新卒1年目、はじめてのアプリケーションサーバー【IBM WebSphere Liberty】
ktgrryt
0
180
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
How to Ace a Technical Interview
jacobian
276
23k
We Have a Design System, Now What?
morganepeng
51
7.4k
What's in a price? How to price your products and services
michaelherold
244
12k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Into the Great Unknown - MozCon
thekraken
34
1.6k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
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