https://github.com/val-bubbleflat/laravel-echo-ios
A wrapper for Laravel Echo in Swift
https://github.com/val-bubbleflat/laravel-echo-ios
laravel laravel-echo socket swift
Last synced: 4 months ago
JSON representation
A wrapper for Laravel Echo in Swift
- Host: GitHub
- URL: https://github.com/val-bubbleflat/laravel-echo-ios
- Owner: val-bubbleflat
- License: mit
- Created: 2017-10-17T09:11:36.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-22T15:51:55.000Z (over 5 years ago)
- Last Synced: 2025-12-03T15:27:11.237Z (7 months ago)
- Topics: laravel, laravel-echo, socket, swift
- Language: Swift
- Size: 19.5 KB
- Stars: 21
- Watchers: 2
- Forks: 18
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Echo IOS
This is a project by [Bubbleflat : find your perfect roommate and flatsharing](https://bubbleflat.com)
This project is wrapper to use [Laravel Echo](https://github.com/laravel/echo) in Swift IOS project
This only work for **socket.io**, NOT FOR PUSHER yet !
## Installation
This module can be imported with CocoaPods
```
pod 'LaravelEchoIOS'
```
## Example
First, you need to import the framework :
```Swift
import LaravelEchoIOS
```
Then you can use it like in javascript ( but you need to wait for the socket to be connected )
```Swift
let token = "Auth token"
let e : Echo = Echo(options: ["host":"http://localhost:6001", "auth": ["headers": ["Authorization": "Bearer " + token]]])
e.connected(){ data, ack in
print("CONNECTED")
e.join(channel: "conversation.243").listen(event: ".NewMessage", callback: { data, ack in
print(data)
})
}
```
## Documentation
See [full Echo documentation](https://laravel.com/docs/5.5/broadcasting) for all available methods
All callback must been use like this :
```Swift
e.connected(){ data, ack in
// Do something when call
}
```
Or with a function like this
```Swift
func listener(data: [Any], ack: SocketAckEmitter)
```
**here, joining, leaving are not available yet**