Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS 14からのアプリ内課金

iOS 14からのアプリ内課金

#potatotips #71での発表資料です。
https://potatotips.connpass.com/event/189012/

より詳しい内容はこちら
https://zenn.dev/tattn/books/ios14-in-app-purchase

おすすめ: iOS 14対応で気をつけるべきこと
https://zenn.dev/tattn/articles/40d1e53cc63d381a3ac5

Twitter: https://twitter.com/tanakasan2525

Tatsuya Tanaka

October 23, 2020
Tweet

More Decks by Tatsuya Tanaka

Other Decks in Technology

Transcript

  1. Ϣχοτςετͷ४උ import XCTest import StoreKitTest override func setUpWithError() throws {

    // ςετ؀ڥΛ࡞੒ (.storekitϑΝΠϧͷಡΈࠐΈ) session = try SKTestSession(configurationFileNamed: "Configuration") // ՝ۚγʔτͳͲΛදࣔ͠ͳ͍Α͏ʹ͢Δ session.disableDialogs = true // ઃఆΛॳظԽ͢Δ session.resetToDefaultState() // τϥϯβΫγϣϯΛϦηοτ͢Δ session.clearTransactions() } μΠΞϩά΍OSͷ՝ۚγʔτͳͲΛඇදࣔʹͨ͠Γɺ ՝ۚཤྺΛϦηοτͨ͠ΓͰ͖Δ
  2. ߪೖࣦഊͷςετ 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ઃఆΛ͢Δͱ ڧ੍తʹߪೖࣦഊͤ͞Δ͜ͱ͕Ͱ͖Δ