diff --git a/FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h b/FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h index cbe202ec6a8..b04ed7446d7 100644 --- a/FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h +++ b/FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h @@ -27,11 +27,6 @@ NS_ASSUME_NONNULL_BEGIN -/// Completion handler invoked after a fetch that contains the updated keys -typedef void (^RCNConfigFetchCompletion)(FIRRemoteConfigFetchStatus status, - FIRRemoteConfigUpdate *update, - NSError *error); - @interface RCNConfigFetch : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -58,7 +53,9 @@ typedef void (^RCNConfigFetchCompletion)(FIRRemoteConfigFetchStatus status, /// @param fetchAttemptNumber The number of the fetch attempt. /// @param completionHandler Callback handler. - (void)realtimeFetchConfigWithNoExpirationDuration:(NSInteger)fetchAttemptNumber - completionHandler:(RCNConfigFetchCompletion)completionHandler; + completionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))completionHandler; /// Add the ability to update NSURLSession's timeout after a session has already been created. - (void)recreateNetworkSession; diff --git a/FirebaseRemoteConfig/Sources/RCNConfigFetch.m b/FirebaseRemoteConfig/Sources/RCNConfigFetch.m index 89da1c7bb41..47b100703c8 100644 --- a/FirebaseRemoteConfig/Sources/RCNConfigFetch.m +++ b/FirebaseRemoteConfig/Sources/RCNConfigFetch.m @@ -199,7 +199,9 @@ - (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration #pragma mark - Fetch helpers - (void)realtimeFetchConfigWithNoExpirationDuration:(NSInteger)fetchAttemptNumber - completionHandler:(RCNConfigFetchCompletion)completionHandler { + completionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))completionHandler { // Note: We expect the googleAppID to always be available. BOOL hasDeviceContextChanged = [Device remoteConfigHasDeviceContextChanged:_settings.deviceContext projectIdentifier:_options.googleAppID]; @@ -246,7 +248,9 @@ - (NSString *)FIRAppNameFromFullyQualifiedNamespace { /// requests to work.(b/14751422). - (void)refreshInstallationsTokenWithFetchHeader:(NSString *)fetchTypeHeader completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler { + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler { FIRInstallations *installations = [FIRInstallations installationsWithApp:[FIRApp appNamed:[self FIRAppNameFromFullyQualifiedNamespace]]]; if (!installations || !_options.GCMSenderID) { @@ -344,7 +348,9 @@ - (void)refreshInstallationsTokenWithFetchHeader:(NSString *)fetchTypeHeader - (void)doFetchCall:(NSString *)fetchTypeHeader completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler { + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler { [self getAnalyticsUserPropertiesWithCompletionHandler:^(NSDictionary *userProperties) { dispatch_async(self->_lockQueue, ^{ [self fetchWithUserProperties:userProperties @@ -380,7 +386,9 @@ - (void)reportCompletionWithStatus:(FIRRemoteConfigFetchStatus)status withUpdate:(FIRRemoteConfigUpdate *)update withError:(NSError *)error completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler { + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler { if (completionHandler) { dispatch_async(dispatch_get_main_queue(), ^{ completionHandler(status, error); @@ -397,7 +405,9 @@ - (void)reportCompletionWithStatus:(FIRRemoteConfigFetchStatus)status - (void)fetchWithUserProperties:(NSDictionary *)userProperties fetchTypeHeader:(NSString *)fetchTypeHeader completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler { + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler { FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000061", @"Fetch with user properties initiated."); NSString *postRequestString = [_settings nextRequestWithUserProperties:userProperties]; diff --git a/FirebaseRemoteConfig/Tests/Swift/ObjC/FetchMocks.m b/FirebaseRemoteConfig/Tests/Swift/ObjC/FetchMocks.m index 30300a61e3a..7ef90f374fa 100644 --- a/FirebaseRemoteConfig/Tests/Swift/ObjC/FetchMocks.m +++ b/FirebaseRemoteConfig/Tests/Swift/ObjC/FetchMocks.m @@ -20,10 +20,14 @@ @interface RCNConfigFetch (ExposedForTest) - (void)refreshInstallationsTokenWithFetchHeader:(NSString *)fetchTypeHeader completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler; + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler; - (void)doFetchCall:(NSString *)fetchTypeHeader completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler; + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler; @end @implementation FetchMocks diff --git a/FirebaseRemoteConfig/Tests/Unit/RCNPersonalizationTest.m b/FirebaseRemoteConfig/Tests/Unit/RCNPersonalizationTest.m index 5ecbe418647..dc642d9e0d6 100644 --- a/FirebaseRemoteConfig/Tests/Unit/RCNPersonalizationTest.m +++ b/FirebaseRemoteConfig/Tests/Unit/RCNPersonalizationTest.m @@ -39,7 +39,9 @@ - (NSURLSessionDataTask *)URLSessionDataTaskWithContent:(NSData *)content - (void)fetchWithUserProperties:(NSDictionary *)userProperties fetchTypeHeader:(NSString *)fetchTypeHeader completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler; + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler; @end @interface RCNPersonalizationTest : XCTestCase { diff --git a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m index 21949b58215..762297e2b0e 100644 --- a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m +++ b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m @@ -55,11 +55,15 @@ - (NSURLSessionDataTask *)URLSessionDataTaskWithContent:(NSData *)content - (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler; - (void)realtimeFetchConfigWithNoExpirationDuration:(NSInteger)fetchAttemptNumber - completionHandler:(RCNConfigFetchCompletion)completionHandler; + completionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))completionHandler; - (void)fetchWithUserProperties:(NSDictionary *)userProperties fetchTypeHeader:(NSString *)fetchTypeHeader completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler - updateCompletionHandler:(RCNConfigFetchCompletion)updateCompletionHandler; + updateCompletionHandler:(void (^)(FIRRemoteConfigFetchStatus status, + FIRRemoteConfigUpdate *update, + NSError *error))updateCompletionHandler; - (NSString *)constructServerURL; - (NSURLSession *)currentNetworkSession; @end