Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Jan 14, 2025
1 parent 8d373c7 commit 92fc00c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
37 changes: 19 additions & 18 deletions FirebaseRemoteConfig/SwiftNew/RemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
public func fetch(withExpirationDuration expirationDuration: TimeInterval) async throws
-> RemoteConfigFetchStatus {
return try await withCheckedThrowingContinuation { continuation in
self.fetch(withExpirationDuration: expirationDuration) { status, error in
return try await withUnsafeThrowingContinuation { continuation in
configFetch.fetchConfig(withExpirationDuration: expirationDuration) { status, error in
if let error {
continuation.resume(throwing: error)
} else {
Expand Down Expand Up @@ -512,14 +512,12 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
/// and avoid calling this method again.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
public func fetchAndActivate() async throws -> RemoteConfigFetchAndActivateStatus {
return try await withCheckedThrowingContinuation { continuation in
self.fetchAndActivate { status, error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: status)
}
}
_ = try await fetch()
do {
try await activate()
return .successFetchedFromRemote
} catch {
return .successUsingPreFetchedData
}
}

Expand All @@ -537,23 +535,25 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
@objc public func fetchAndActivate(completionHandler:
((RemoteConfigFetchAndActivateStatus, Error?) -> Void)? =
nil) {
fetch { [weak self] status, error in
fetch { [weak self] fetchStatus, error in
guard let self = self else { return }
// Fetch completed. We are being called on the main queue.
// If fetch is successful, try to activate the fetched config
if status == .success, error == nil {
if fetchStatus == .success, error == nil {
self.activate { changed, error in
let status: RemoteConfigFetchAndActivateStatus = error == nil ?
.successFetchedFromRemote : .successUsingPreFetchedData
if let completionHandler {
DispatchQueue.main.async {
let status: RemoteConfigFetchAndActivateStatus = error == nil ?
.successFetchedFromRemote : .successUsingPreFetchedData
completionHandler(status, nil)
}
}
}
} else if let completionHandler {
DispatchQueue.main.async {
completionHandler(.error, error)
let status: RemoteConfigFetchAndActivateStatus = fetchStatus == .success ?
.successFetchedFromRemote : .error
completionHandler(status, error)
}
}
}
Expand All @@ -565,8 +565,9 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
/// appearance of the app to take effect (depending on how config data is used in the app).
/// - Returns A Bool indicating whether or not a change occurred.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
public func activate() async throws -> Bool {
return try await withCheckedThrowingContinuation { continuation in
return try await withUnsafeThrowingContinuation { continuation in
self.activate { updated, error in
if let error {
continuation.resume(throwing: error)
Expand Down Expand Up @@ -634,9 +635,9 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
DispatchQueue.main.async {
self.notifyConfigHasActivated()
}
self.configExperiment.updateExperiments { error in
self.configExperiment.updateExperiments { _ in
DispatchQueue.main.async {
completion?(true, error)
completion?(true, nil)
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import <FirebaseRemoteConfig/FirebaseRemoteConfig-Swift.h>

#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
#import "FirebaseRemoteConfig/Tests/Unit/RCNTestUtilities.h"
@import FirebaseRemoteConfigInterop;

Expand Down

0 comments on commit 92fc00c

Please sign in to comment.