Skip to content

Commit 9f25a01

Browse files
Refactor API to enforce non-null dictionary and improve naming
1 parent 7fa9ed0 commit 9f25a01

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,9 @@ - (void)callListeners:(NSString *)key config:(NSDictionary *)config {
246246
}
247247
}
248248

249-
- (void)setCustomSignals:(nullable NSDictionary<NSString *, NSObject *> *)customSignals
250-
WithCompletion:(void (^_Nullable)(NSError *_Nullable error))completionHandler {
249+
- (void)setCustomSignals:(nonnull NSDictionary<NSString *, NSObject *> *)customSignals
250+
withCompletion:(void (^_Nullable)(NSError *_Nullable error))completionHandler {
251251
void (^setCustomSignalsBlock)(void) = ^{
252-
if (!customSignals) {
253-
if (completionHandler) {
254-
dispatch_async(dispatch_get_main_queue(), ^{
255-
completionHandler(nil);
256-
});
257-
}
258-
return;
259-
}
260-
261252
// Validate value type, and key and value length
262253
for (NSString *key in customSignals) {
263254
NSObject *value = customSignals[key];

FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable
370370
(FIRRemoteConfigUpdateCompletion _Nonnull)listener
371371
NS_SWIFT_NAME(addOnConfigUpdateListener(remoteConfigUpdateCompletion:));
372372

373-
- (void)setCustomSignals:(nullable NSDictionary<NSString *, NSObject *> *)customSignals
374-
WithCompletion:(void (^_Nullable)(NSError *_Nullable error))completionHandler
373+
- (void)setCustomSignals:(nonnull NSDictionary<NSString *, NSObject *> *)customSignals
374+
withCompletion:(void (^_Nullable)(NSError *_Nullable error))completionHandler
375375
NS_REFINED_FOR_SWIFT;
376376

377377
@end

FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ - (void)testFetchAndActivateRolloutsNotifyInterop {
18341834
[self waitForExpectations:@[ notificationExpectation ] timeout:_expectationTimeout];
18351835
}
18361836

1837-
- (void)testSetCustomSingals {
1837+
- (void)testSetCustomSignals {
18381838
NSMutableArray<XCTestExpectation *> *expectations =
18391839
[[NSMutableArray alloc] initWithCapacity:RCNTestRCNumTotalInstances];
18401840

@@ -1849,7 +1849,7 @@ - (void)testSetCustomSingals {
18491849
};
18501850

18511851
[_configInstances[i] setCustomSignals:testSignals
1852-
WithCompletion:^(NSError *_Nullable error) {
1852+
withCompletion:^(NSError *_Nullable error) {
18531853
XCTAssertNil(error);
18541854
NSMutableDictionary<NSString *, NSString *> *retrievedSignals =
18551855
self->_configInstances[i].settings.customSignals;
@@ -1889,11 +1889,11 @@ - (void)testSetCustomSignalsMultipleTimes {
18891889
};
18901890

18911891
[_configInstances[i] setCustomSignals:testSignals1
1892-
WithCompletion:^(NSError *_Nullable error) {
1892+
withCompletion:^(NSError *_Nullable error) {
18931893
XCTAssertNil(error);
18941894
[_configInstances[i]
18951895
setCustomSignals:testSignals2
1896-
WithCompletion:^(NSError *_Nullable error) {
1896+
withCompletion:^(NSError *_Nullable error) {
18971897
XCTAssertNil(error);
18981898
NSMutableDictionary<NSString *, NSString *> *retrievedSignals =
18991899
self->_configInstances[i].settings.customSignals;
@@ -1927,19 +1927,19 @@ - (void)testSetCustomSignals_invalidInput_throwsException {
19271927

19281928
[_configInstances[i]
19291929
setCustomSignals:invalidSignals1
1930-
WithCompletion:^(NSError *_Nullable error) {
1930+
withCompletion:^(NSError *_Nullable error) {
19311931
XCTAssertNotNil(error);
19321932
XCTAssertEqual(error.code, FIRRemoteConfigCustomSignalsErrorInvalidValueType);
19331933
}];
19341934
[_configInstances[i]
19351935
setCustomSignals:invalidSignals2
1936-
WithCompletion:^(NSError *_Nullable error) {
1936+
withCompletion:^(NSError *_Nullable error) {
19371937
XCTAssertNotNil(error);
19381938
XCTAssertEqual(error.code, FIRRemoteConfigCustomSignalsErrorLimitExceeded);
19391939
}];
19401940
[_configInstances[i]
19411941
setCustomSignals:invalidSignals3
1942-
WithCompletion:^(NSError *_Nullable error) {
1942+
withCompletion:^(NSError *_Nullable error) {
19431943
XCTAssertNotNil(error);
19441944
XCTAssertEqual(error.code, FIRRemoteConfigCustomSignalsErrorLimitExceeded);
19451945
[expectations[i] fulfill];

0 commit comments

Comments
 (0)