-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Hi,
I am trying to convert a JSONCodable object to a JSONCodableScalar and this is failing. the object itself is a representation of json data (with nested values as well). how can I make this work in order to set my presence state, I fail in the second guard statement
`
func setState(stateCodable: JsonCodable) {
let encoder = JSONEncoder()
guard let data = try? encoder.encode(stateCodable) else {
return
}
guard let state = try? JSONSerialization.jsonObject(with: data) as? [String: JSONCodableScalar] else {
return
}
pubnub.setPresence(
state: state,
on: ["channel"]
) { result in
switch result {
case let .success(response):
print("Successful Set State Response: \(response)")
case let .failure(error):
print("Failed Set State Response: \(error.localizedDescription)")
}
}
}
`
thank you
Metadata
Metadata
Assignees
Labels
No labels