@@ -469,8 +469,8 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
469469 @available ( iOS 13 , tvOS 13 , macOS 10 . 15 , macCatalyst 13 , watchOS 7 , * )
470470 public func fetch( withExpirationDuration expirationDuration: TimeInterval ) async throws
471471 -> RemoteConfigFetchStatus {
472- return try await withCheckedThrowingContinuation { continuation in
473- self . fetch ( withExpirationDuration: expirationDuration) { status, error in
472+ return try await withUnsafeThrowingContinuation { continuation in
473+ configFetch . fetchConfig ( withExpirationDuration: expirationDuration) { status, error in
474474 if let error {
475475 continuation. resume ( throwing: error)
476476 } else {
@@ -512,14 +512,12 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
512512 /// and avoid calling this method again.
513513 @available ( iOS 13 , tvOS 13 , macOS 10 . 15 , macCatalyst 13 , watchOS 7 , * )
514514 public func fetchAndActivate( ) async throws -> RemoteConfigFetchAndActivateStatus {
515- return try await withCheckedThrowingContinuation { continuation in
516- self . fetchAndActivate { status, error in
517- if let error {
518- continuation. resume ( throwing: error)
519- } else {
520- continuation. resume ( returning: status)
521- }
522- }
515+ _ = try await fetch ( )
516+ do {
517+ try await activate ( )
518+ return . successFetchedFromRemote
519+ } catch {
520+ return . successUsingPreFetchedData
523521 }
524522 }
525523
@@ -537,23 +535,25 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
537535 @objc public func fetchAndActivate( completionHandler:
538536 ( ( RemoteConfigFetchAndActivateStatus , Error ? ) -> Void ) ? =
539537 nil ) {
540- fetch { [ weak self] status , error in
538+ fetch { [ weak self] fetchStatus , error in
541539 guard let self = self else { return }
542540 // Fetch completed. We are being called on the main queue.
543541 // If fetch is successful, try to activate the fetched config
544- if status == . success, error == nil {
542+ if fetchStatus == . success, error == nil {
545543 self . activate { changed, error in
546- let status : RemoteConfigFetchAndActivateStatus = error == nil ?
547- . successFetchedFromRemote : . successUsingPreFetchedData
548544 if let completionHandler {
549545 DispatchQueue . main. async {
546+ let status : RemoteConfigFetchAndActivateStatus = error == nil ?
547+ . successFetchedFromRemote : . successUsingPreFetchedData
550548 completionHandler ( status, nil )
551549 }
552550 }
553551 }
554552 } else if let completionHandler {
555553 DispatchQueue . main. async {
556- completionHandler ( . error, error)
554+ let status : RemoteConfigFetchAndActivateStatus = fetchStatus == . success ?
555+ . successFetchedFromRemote : . error
556+ completionHandler ( status, error)
557557 }
558558 }
559559 }
@@ -565,8 +565,9 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
565565 /// appearance of the app to take effect (depending on how config data is used in the app).
566566 /// - Returns A Bool indicating whether or not a change occurred.
567567 @available ( iOS 13 , tvOS 13 , macOS 10 . 15 , macCatalyst 13 , watchOS 7 , * )
568+ @discardableResult
568569 public func activate( ) async throws -> Bool {
569- return try await withCheckedThrowingContinuation { continuation in
570+ return try await withUnsafeThrowingContinuation { continuation in
570571 self . activate { updated, error in
571572 if let error {
572573 continuation. resume ( throwing: error)
@@ -634,9 +635,9 @@ open class RemoteConfig: NSObject, NSFastEnumeration {
634635 DispatchQueue . main. async {
635636 self . notifyConfigHasActivated ( )
636637 }
637- self . configExperiment. updateExperiments { error in
638+ self . configExperiment. updateExperiments { _ in
638639 DispatchQueue . main. async {
639- completion ? ( true , error )
640+ completion ? ( true , nil )
640641 }
641642 }
642643 } else {
0 commit comments