Skip to content

Commit

Permalink
chore: try to fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Mar 4, 2024
1 parent d8638a4 commit 4cffadb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci-example-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

jobs:
build_ios_example:
runs-on: macos-latest
runs-on: macos-14

steps:
- name: Checkout repository
Expand Down Expand Up @@ -48,6 +48,9 @@ jobs:
bundler-cache: true
ruby-version: '2.7'

- name: Install SwiftLint
run: brew install swiftlint

- name: SwiftLint
run: swiftlint lint --fix --format --path ios/*.swift --config .swiftlint.yml

Expand Down
11 changes: 7 additions & 4 deletions ios/IapUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import StoreKit
import React

public func debugMessage(_ object: Any...) {
#if DEBUG
Expand All @@ -30,8 +31,10 @@ func checkVerified<T>(_ result: VerificationResult<T>) throws -> T {
}

@available(iOS 15.0, *)
func currentWindow() -> UIWindow? {
return UIApplication.shared.connectedScenes
.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
.last { $0.isKeyWindow }
func currentWindow() async -> UIWindow? {
await withCheckedContinuation { continuation in
DispatchQueue.main.async {
continuation.resume(returning: RCTKeyWindow())
}
}
}
23 changes: 10 additions & 13 deletions ios/RNIapIosSk2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -961,22 +961,20 @@ class RNIapIosSk2iOS15: Sk2Delegate {
reject: @escaping RCTPromiseRejectBlock = { _, _, _ in }
) {
#if !os(tvOS)
DispatchQueue.main.async {
guard let scene = currentWindow()?.windowScene as? UIWindowScene,
Task {
guard let scene = await currentWindow()?.windowScene as? UIWindowScene,
!ProcessInfo.processInfo.isiOSAppOnMac else {
return
}

Task {
do {
try await AppStore.showManageSubscriptions(in: scene)
} catch {
print("Error:(error)")
}

do {
try await AppStore.showManageSubscriptions(in: scene)
} catch {
print("Error:(error)")
}

resolve(nil)
}

resolve(nil)
#else
reject(IapErrors.E_USER_CANCELLED.rawValue, "This method is not available on tvOS", nil)
#endif
Expand Down Expand Up @@ -1013,9 +1011,8 @@ class RNIapIosSk2iOS15: Sk2Delegate {
}
}

let window = currentWindow()

Task {
let window = await currentWindow()
if let windowScene = await window?.windowScene {
if let product = await productStore.getProduct(productID: sku) {
if let result = await product.latestTransaction {
Expand Down

0 comments on commit 4cffadb

Please sign in to comment.