Client library
Realtime iOS (Swift) with WebSockets Native iOS and macOS apps with the official Swift library.
Sign in to see these snippets with your own cluster host. Sign in
Using an AI coding agent? Copy the agent prompt ↓
Install
https://github.com/pusher/pusher-websocket-swiftSubscribe to a channel import PusherSwift
let options = PusherClientOptions (
host: .host("ws.hibira.io" ),
port: 443 ,
useTLS: true
)
let pusher = Pusher (key: "YOUR_APP_KEY" , options: options)
pusher.connect()
let channel = pusher.subscribe("orders" )
channel.bind(eventName: "order-shipped" ) { (event: PusherEvent ) in
print (event.data ?? "" )
}Agent prompt Paste this into Claude Code, Cursor, GitHub Copilot or another AI coding agent, and it will wire Hibira into your iOS (Swift) project with the settings above.
Integrate Hibira realtime messaging into this iOS (Swift) project. Hibira is a hosted WebSocket service that speaks the Pusher Channels protocol, so it works with the standard Pusher libraries (here: PusherSwift, https://github.com/pusher/pusher-websocket-swift) pointed at Hibira instead of pusher.com.
Connection details:
- Host: ws.hibira.io
- Port: 443
- TLS: yes (https)
- App key: YOUR_APP_KEY
- No app secret: it belongs on the server, never in this app
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Add PusherSwift with Swift Package Manager (or the project's existing CocoaPods setup).
3. Wrap the connection in one service object (for example RealtimeService) that the app shares; read the key and host from an xcconfig or Info.plist entry, not a hard-coded string.
4. Connect when the app becomes active, disconnect when it goes to the background, and update UI on the main thread.
5. If the app needs private or presence channels, set authMethod to the backend's auth endpoint; the app secret must never be in the iOS app.
6. Read the credentials and host from environment variables or the project's config, and add placeholder entries to .env.example (or its equivalent). Never commit real values.
7. Always pass the host, port and TLS setting above. The library defaults to pusher.com; where it requires a cluster, use "ap" (the host decides where it connects).
8. If YOUR_APP_KEY above is still a placeholder, keep it as an env placeholder and tell me where to fill it in rather than inventing a value.
9. When you are done, list the files you changed and tell me how to check it works, for example by publishing a test event and watching it arrive.
Reference setup from the Hibira iOS (Swift) guide (adapt it to the project's structure):
Install:
```shell
# Swift Package Manager
https://github.com/pusher/pusher-websocket-swift
```
Subscribe to a channel:
```swift
import PusherSwift
let options = PusherClientOptions(
host: .host("ws.hibira.io"),
port: 443,
useTLS: true
)
let pusher = Pusher(key: "YOUR_APP_KEY", options: options)
pusher.connect()
let channel = pusher.subscribe("orders")
channel.bind(eventName: "order-shipped") { (event: PusherEvent) in
print(event.data ?? "")
}
```
Replace YOUR_APP_KEY and the other placeholders with the values from your dashboard, or let the agent leave them as environment variables for you to fill in.
Or connect the Hibira MCP server, and your agent can create the app and fill in its credentials itself. Connect your AI coding agent →
Use the app key and secret from your dashboard. Channels, events and authorization endpoints work exactly as they do with Pusher. Library reference ↗