Slide 1

Slide 1 text

iOS 14͔Βͷ՝࣮ۚ૷ ాதୡ໵ (@tattn) #potatotips (#71)

Slide 2

Slide 2 text

ాத ୡ໵ / ͨͳͨͭ (@tattn) • Yahoo!ΧʔφϏ • Yahoo!৐׵Ҋ಺ • શࣾԣஅνʔϜ @tattn @tanakasan2525 @tattn

Slide 3

Slide 3 text

iOS 14ରԠͷهࣄॻ͖·ͨ͠ IUUQT[FOOEFWUBUUOBSUJDMFT EFDDEBBD

Slide 4

Slide 4 text

͜Ε·Ͱͷ՝࣮ۚ૷Ͱؾʹͳ͍ͬͯͨ఺ ࣮ػ͕ඞཁ ಈ࡞֬ೝ͕ ΍Γʹ͍͘ Ϣχοτςετ ΍Γʹ͍͘

Slide 5

Slide 5 text

͜Ε·Ͱͷ՝࣮ۚ૷Ͱؾʹͳ͍ͬͯͨ఺ ࣮ػ͕ඞཁ ಈ࡞֬ೝ͕ ΍Γʹ͍͘ Ϣχοτςετ ΍Γʹ͍͘ Xcode 12/iOS 14Ͱ͸ େ෯ʹվળ͠·ͨ͠

Slide 6

Slide 6 text

͜Ε·Ͱͷ՝࣮ۚ૷Ͱؾʹͳ͍ͬͯͨ఺ ࣮ػ͕ඞཁ ಈ࡞֬ೝ͕ ΍Γʹ͍͘ Ϣχοτςετ ΍Γʹ͍͘

Slide 7

Slide 7 text

StoreKit Configuration Xcode 12ʹStorekit Configurationͱ͍͏ػೳ͕ೖΓɺ App Storeͱ઀ଓͤͣʹ঎඼ͷऔಘ΍՝ۚͳͲ͕ςετͰ͖ΔΑ͏ʹ →SimulatorͰ΋՝ۚॲཧ͕ࢼͤΔΑ͏ʹ

Slide 8

Slide 8 text

StoreKit Configurationͷ༗ޮԽ Edit Scheme͔Β࢖༻͢ΔઃఆΛબͿ

Slide 9

Slide 9 text

঎඼ͷઃఆ App Store ConnectͰઃఆ͢Δͷͱ΄΅ಉ͡಺༰Ͱ αϒεΫϦϓγϣϯ΍ফ໣ܕ/ඇফ໣ܕͷ঎඼ઃఆ͕Ͱ͖Δ

Slide 10

Slide 10 text

γϛϡϨʔλͰ΋՝ۚՄೳʹ let payment = SKPayment(product: product) SKPaymentQueue.default().add(payment) ޙ͸StoreKitͰߪೖॲཧΛ࣮૷͢Δͱ γϛϡϨʔλͰ΋OSͷߪೖγʔτ͕දࣔ͞Εɺ ՝ۚͷςετ͕Ͱ͖Δ

Slide 11

Slide 11 text

͜Ε·Ͱͷ՝࣮ۚ૷Ͱؾʹͳ͍ͬͯͨ఺ ࣮ػ͕ඞཁ ಈ࡞֬ೝ͕ ΍Γʹ͍͘ Ϣχοτςετ ΍Γʹ͍͘

Slide 12

Slide 12 text

͜Ε·Ͱͷ՝࣮ۚ૷Ͱؾʹͳ͍ͬͯͨ఺ ࣮ػ͕ඞཁ ಈ࡞֬ೝ͕ ΍Γʹ͍͘ Ϣχοτςετ ΍Γʹ͍͘

Slide 13

Slide 13 text

ΞϓϦ֎͔Βͷ՝ۚͷςετ

Slide 14

Slide 14 text

αϒεΫϦϓγϣϯͷߪಡ͸ΞϓϦ֎͔Β΋Ͱ͖Δ Ұ౓ߪಡͨ͠αϒεΫϦϓγϣϯ͸ ઃఆΞϓϦ౳͔Β࠶ߪಡͰ͖Δ IUUQTTVQQPSUBQQMFDPNKBKQ)5

Slide 15

Slide 15 text

iOS 14͔ΒSandbox؀ڥͰαϒεΫϦϓγϣϯͷ؅ཧ͕Մೳʹ ઃఆΞϓϦΛ։͘ App Store SandboxΞΧ΢ϯτʮApple ID: ***ʯ ؅ཧ

Slide 16

Slide 16 text

Ask To Buy

Slide 17

Slide 17 text

Ask To Buy (ঝೝͱߪೖͷϦΫΤετ) ࢠڙ͕՝ۚΞΠςϜΛߪೖ͢ΔλΠϛϯάͰ਌ʹ௨஌Λඈ͹͠ɺ ঝೝ͞ΕΔ·ͰߪೖΛ஗Ԇͤ͞Δػೳ .deferred .purchased SKPaymentTransaction ঝೝ IUUQTTVQQPSUBQQMFDPNKBKQ)5

Slide 18

Slide 18 text

ࠓ·Ͱ͸ຊ൪ͷΑ͏ͳ஗Ԇߪೖ͕Ͱ͖ͳ͔ͬͨ simulatesAskToBuyInSandboxͱ͍͏ϓϩύςΟΛtrueʹ͢Δͱ ߪೖ࣌ʹঝೝΞϥʔτ͸ग़Δ͕ɺͦͷޙͷߪೖ͕Ͱ͖ͳ͔ͬͨ .deferred .purchased SKPaymentTransaction ݺ͹Εͳ͍ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOTUPSFLJUTLQBZNFOUTJNVMBUFTBTLUPCVZJOTBOECPY

Slide 19

Slide 19 text

Xcode؀ڥͰͷAsk To Buyͷςετ Xcodeͷσόοά࣮ߦ؀ڥͳΒ τϥϯβΫγϣϯͷ؅ཧը໘Ͱঝೝorඇঝೝͷૢ࡞͕Մೳʹ .deferred .purchased SKPaymentTransaction Λԡ͢

Slide 20

Slide 20 text

Manage StoreKit Transactions XcodeʹτϥϯβΫγϣϯͷ؅ཧը໘͕௥Ճ ߪೖཤྺͷ࡟আɺฦۚɺ՝ۚͷதஅͳͲ΋σόοά͕Մೳʹ

Slide 21

Slide 21 text

͜Ε·Ͱͷ՝࣮ۚ૷Ͱؾʹͳ͍ͬͯͨ఺ ࣮ػ͕ඞཁ ಈ࡞֬ೝ͕ ΍Γʹ͍͘ Ϣχοτςετ ΍Γʹ͍͘

Slide 22

Slide 22 text

͜Ε·Ͱͷ՝࣮ۚ૷Ͱؾʹͳ͍ͬͯͨ఺ ࣮ػ͕ඞཁ ಈ࡞֬ೝ͕ ΍Γʹ͍͘ Ϣχοτςετ ΍Γʹ͍͘

Slide 23

Slide 23 text

StoreKitTest StoreKitͷΫϥεΛϞοΫԽ͠ͳͯ͘΋ StoreKitͷಈ࡞ΛมߋͰ͖ΔStoreKitTestϑϨʔϜϫʔΫ͕ొ৔ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOTUPSFLJUUFTU

Slide 24

Slide 24 text

Ϣχοτςετͷ४උ import XCTest import StoreKitTest override func setUpWithError() throws { // ςετ؀ڥΛ࡞੒ (.storekitϑΝΠϧͷಡΈࠐΈ) session = try SKTestSession(configurationFileNamed: "Configuration") // ՝ۚγʔτͳͲΛදࣔ͠ͳ͍Α͏ʹ͢Δ session.disableDialogs = true // ઃఆΛॳظԽ͢Δ session.resetToDefaultState() // τϥϯβΫγϣϯΛϦηοτ͢Δ session.clearTransactions() } μΠΞϩά΍OSͷ՝ۚγʔτͳͲΛඇදࣔʹͨ͠Γɺ ՝ۚཤྺΛϦηοτͨ͠ΓͰ͖Δ

Slide 25

Slide 25 text

ߪೖࣦഊͷςετ func testFailed() throws { // ߪೖΛࣦഊͤ͞Δ session.failTransactionsEnabled = true session.failureError = .invalidSignature // ߪೖ try session.buyProduct(productIdentifier: ProductId.premium.rawValue) XCTAssertEqual(session.allTransactions()[0].state, .failed) // ߪೖঢ়ଶͷ֬ೝ XCTAssertFalse(PurchaseManager.shared.isAvailable(for: .premium)) } sessionͰfailઃఆΛ͢Δͱ ڧ੍తʹߪೖࣦഊͤ͞Δ͜ͱ͕Ͱ͖Δ

Slide 26

Slide 26 text

આ໌͖͠Εͳ͔ͬͨ৽ػೳ Xcode؀ڥͷϨγʔτݕূ ࣌ؒܦաͷߴ଎Խ ฦۚॲཧͷςετ ϑΝϛϦʔڞ༗ ϓϩϞʔγϣϯΦϑΝʔ αʔόʔ௨஌ Ϣχοτςετͷͦͷଞͷ৽ػೳ ࣮ࡍͷৄࡉͳ࣮૷ Xcode 12ͷϫʔΫΞϥ΢ϯυ Τϥʔέʔεͷݕূ ͓ࢼ͠ΦϑΝʔ

Slide 27

Slide 27 text

ZennͷBooksͰৄ͍͠ղઆͱ࣮૷Λެ։͠·ͨ͠ ໢ཏతͳ৽ػೳΛ঺հͱ SwiftUI੡ͷׂͱ͔ͬ͠Γ࣮૷ͨ͠՝ۚαϯϓϧΞϓϦ͕ࡌͬͯ·͢ IUUQT[FOOEFWUBUUOCPPLTJPTJOBQQQVSDIBTF