Created
May 20, 2018 01:53
-
-
Save kennyhorna/ba4c15a5991ac14e9d8e1fb7de13ba0c to your computer and use it in GitHub Desktop.
This file contains 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
// Acá está la documentación: https://pusher.com/docs/ios_quick_start | |
/* | |
* CONEXIÓN | |
*/ | |
let options = PusherClientOptions( | |
host: .cluster("YOUR_CLUSTER") // credenciales | |
) | |
let pusher = Pusher(key: "YOUR_APP_KEY", options: options) // credenciales | |
pusher.connect() | |
/* | |
* SUSCRIBIRTE A UN CANAL | |
*/ | |
let myChannel = pusher.subscribe("venue" + venue_id) // acá se especifica el local (venue) al cual se está suscribiendo | |
/* | |
* ESCUCHAR UN EVENTO ("reservation.created", "reservation.cancelled", "reservation.confirmed") | |
*/ | |
let _ = myChannel.bind(eventName: "reservation.created", callback: { (data: Any?) -> Void in // acá se especifica la acción del evento N | |
if let data = data as? [String : AnyObject] { | |
if let message = data["message"] as? String { | |
print(message) // acá pintas la data del evento N en la vista | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment