File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -201,13 +201,19 @@ extension FirebaseDestination {
201
201
}
202
202
203
203
// Makes sure all traits are string based for Firebase API
204
- func mapToStrings( _ mapDictionary: [ String : Any ] , finalize: ( String , String ) -> Void ) {
204
+ func mapToStrings( _ mapDictionary: [ String : Any ? ] , finalize: ( String , String ) -> Void ) {
205
205
206
206
for (key, data) in mapDictionary {
207
- var dataString = data as? String ?? " \( data) "
208
- let keyString = key. replacingOccurrences ( of: " " , with: " _ " )
209
- dataString = dataString. trimmingCharacters ( in: . whitespacesAndNewlines)
210
- finalize ( keyString, dataString)
207
+
208
+ // Since dictionary values can be Optional we have to unwrap them
209
+ // before encoding so that we don't encode them as "Optional(*)"
210
+ // Note: nil values are NOT encoded.
211
+ if let d = data {
212
+ var dataString = d as? String ?? " \( d) "
213
+ let keyString = key. replacingOccurrences ( of: " " , with: " _ " )
214
+ dataString = dataString. trimmingCharacters ( in: . whitespacesAndNewlines)
215
+ finalize ( keyString, dataString)
216
+ }
211
217
}
212
218
}
213
219
}
You can’t perform that action at this time.
0 commit comments