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 {
201201 }
202202
203203 // 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 ) {
205205
206206 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+ }
211217 }
212218 }
213219}
You can’t perform that action at this time.
0 commit comments