-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARTMessage.data is not converting into Dictionary #643
Comments
Hi @gouravgupta72 . What's the error? |
Does casting to NSDictionary work? We use NSJSONSerialization and I'm not sure the resulting NSDictionary can be bridged to a Dictionary<String, Any>. |
No casting not working, I try NSJSONSerialization as well func convertToDictionary(text: String) -> [String: Any]? { but it's also giving error that data is not in proper format. |
OK, then it probably isn't being properly encoded as a JSON object. How are you publishing this? Can you share some code on the publishing end? |
let messageForServer = ["intentName": "incoming_text",
|
This works for me: self.channel.subscribe { (msg) in
print("MESSAGE \((msg.data as! Dictionary<String, Any>)["hey"])")
}
self.channel.publish(nil, data: ["hey": 123]) Prints as expected:
So I'm not sure what's going on with yours. Can you maybe print Can you confirm you're using the latest version of the library (1.0.9)? |
@gouravgupta72 closing this. Feel free to reopen if it's still an issue. |
Hey folks,
Response in ARTMessage.data is coming as Any, when we try to convert it to Dictionary<String, Any> to get all payload information it is giving error.
Can u help us in solving this.
if msg.data != nil {
if let message = msg.data as! Dictionary <String, Any>
{
// Process message
}
}
The text was updated successfully, but these errors were encountered: