Skip to content

Commit 665da7d

Browse files
authored
fix: Example
fix: Example
2 parents ffcc020 + 2977aa1 commit 665da7d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

.github/workflows/ios-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
build:
99
name: Build and Test default scheme using any available iPhone simulator
10-
runs-on: macos-latest
10+
runs-on: macos-15
1111

1212
steps:
1313
- name: Checkout

Example/MercatoExample/MercatoExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/MercatoExample/MercatoExample/ViewController.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,21 @@ class ViewController: UIViewController {
2828
private var storeKitUpdatesTask: Task<Void, Never>?
2929

3030
private func startObservingStoreKitUpdates() {
31-
storeKitUpdatesTask = Task.detached(priority: .high) { [weak self] in
31+
storeKitUpdatesTask = Task.detached(priority: .high) {
3232
// First, let's finish unfinished txs
3333
for await verificationResult in Mercato.unfinishedTransactions {
34-
guard let self else { break }
35-
36-
do {
37-
try await finish(transactionResult: verificationResult)
38-
} catch {
39-
print(error)
34+
if case .verified(let tx) = verificationResult {
35+
// TODO: Send tx.jsonRepresentation to your server and deliver content to your user.
36+
await tx.finish()
4037
}
4138
}
4239

4340
// Second, subscribe for updates
4441
for await verificationResult in Mercato.updates {
45-
guard let self else { break }
46-
47-
// TODO: Handle updates, send tx on your backend or just verify and update UI
42+
if case .verified(let tx) = verificationResult {
43+
// TODO: Send tx.jsonRepresentation to your server and deliver content to your user.
44+
await tx.finish()
45+
}
4846
}
4947
}
5048
}
@@ -81,6 +79,9 @@ class ViewController: UIViewController {
8179
configureHierarchy()
8280
}
8381

84-
82+
deinit {
83+
storeKitUpdatesTask?.cancel()
84+
storeKitUpdatesTask = nil
85+
}
8586
}
8687

0 commit comments

Comments
 (0)