Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Config] Move away from private typedef (1) #14255

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
20 changes: 15 additions & 5 deletions FirebaseRemoteConfig/Sources/RCNConfigFetch.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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];
Expand Down
8 changes: 6 additions & 2 deletions FirebaseRemoteConfig/Tests/Swift/ObjC/FetchMocks.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion FirebaseRemoteConfig/Tests/Unit/RCNPersonalizationTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading