You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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) {
`
thank you
The text was updated successfully, but these errors were encountered: