Created
April 17, 2023 10:03
-
-
Save snyuryev/9cc7cd44962bba9aede854289eb1efa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
button.onEvent = { event in | |
guard let eventData = event?.data(using: .utf8, allowLossyConversion: false), | |
let eventJson = try? JSONSerialization.jsonObject(with: eventData, options: .mutableContainers), | |
let eventDict = eventJson as? [String: Any], | |
let eventName = eventDict["name"] as? String, | |
let eventText = eventDict["text"] as? String | |
else { | |
return | |
} | |
if eventName == "parsed" { | |
print("YOU: \(eventText)") | |
} else if eventName == "text" { | |
print("Alan: \(eventText)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment