diff --git a/packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m b/packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m index 5b43ac9df7..9fa508849b 100644 --- a/packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m +++ b/packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m @@ -66,7 +66,7 @@ - (dispatch_queue_t)methodQueue { : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { @try { - [FIRAnalytics setUserID:id]; + [FIRAnalytics setUserID:[self convertNSNullToNil:id]]; } @catch (NSException *exception) { return [RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:exception]; } @@ -79,7 +79,7 @@ - (dispatch_queue_t)methodQueue { : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { @try { - [FIRAnalytics setUserPropertyString:value forName:name]; + [FIRAnalytics setUserPropertyString:[self convertNSNullToNil:value] forName:name]; } @catch (NSException *exception) { return [RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:exception]; } @@ -92,7 +92,7 @@ - (dispatch_queue_t)methodQueue { : (RCTPromiseRejectBlock)reject) { @try { [properties enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) { - [FIRAnalytics setUserPropertyString:value forName:key]; + [FIRAnalytics setUserPropertyString:[self convertNSNullToNil:value] forName:key]; }]; } @catch (NSException *exception) { return [RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:exception]; @@ -162,4 +162,10 @@ - (NSDictionary *)cleanJavascriptParams:(NSDictionary *)params { return [newParams copy]; } +/// Converts null values received over the bridge from NSNull to nil +/// @param value Nullable string value +- (NSString *)convertNSNullToNil:(NSString *)value { + return [value isEqual:[NSNull null]] ? nil : value; +} + @end