Install the SDK

To install the SDK, you can use CocoaPods or Swift Package Manager.
pod 'PusherSwift', '~> 8.3.0'

Initialize the SDK

import PusherSwift

let options = PusherClientOptions(
    host: .host("ws.pulses.cloud"),
    encrypted: true
)

let pusher = Pusher(key: "YOUR_APP_KEY", options: options)

Connect to Pusher

pusher.connect()

Subscribe to a channel

let channel = pusher.subscribe("channel-name")

Bind to an event

let _ = channel.bind(eventName: "event-name", callback: { (lastEventId: String?, data: Any?) in
    if let data = data {
        print("Received event with data:", data)
    }
})

Publish an event from the server

To publish an event from the server, you can use the trigger method. Run the following command:
// First, run 'npm install pusher'
const Pusher = require('pusher');

const pusher = new Pusher('YOUR_APP_KEY', {
    wsHost: 'ws.pulses.cloud',
    encrypted: true,
    disableStats: true,
    enabledTransports: ['ws', 'wss'],
    cluster: 'pulses'
});

pusher.trigger('channel-name', 'event-name', {
    message: 'Hello World'
});
If there isn’t an example in a language that you are familiar with then refer to Pusher’s Channels server libraries page to check if anyone has created one in your language.

Unsubscribe from a channel

pusher.unsubscribe("channel-name")

Disconnect from Pusher

pusher.disconnect()