Files
damus/damus/Models/Purple/StoreObserver.swift
Daniel D’Aquino f738aaf358 Increase verbosity of IAP-related logs
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2024-03-11 09:28:15 +00:00

35 lines
845 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// StoreObserver.swift
// damus
//
// Created by Daniel DAquino on 2023-12-08.
//
import Foundation
import StoreKit
class StoreObserver: NSObject, SKPaymentTransactionObserver {
static let standard = StoreObserver()
var delegate: StoreObserverDelegate?
init(delegate: StoreObserverDelegate? = nil) {
self.delegate = delegate
super.init()
}
//Observe transaction updates.
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
//Handle transaction states here.
Log.info("StoreObserver received a transaction update. Notifying to delegate.", for: .damus_purple)
Task {
try await self.delegate?.send_receipt()
}
}
}
protocol StoreObserverDelegate {
func send_receipt() async throws
}