Pusher Flutter Client
Get it from pub.
How to install
- Add to your pubspec.yaml
dependencies: pusher_websocket_flutter: ^0.1.1
/ios/Podfile, set global platform to at least 9.0
platform :ios, '9.0'
For iOS Objective-C based Flutter apps
This set of steps should work to fix this for your project.
use_frameworks!to the end of the Runner section in
- Set Swift version in your iOS Runner project.
- Open the project with Xcode.
- In Runner, File -> New -> File -> Swift File. Name it anything.
- Xcode will ask you if you wish to create Bridging Header, click yes.
- Go to Runner
Build Settingsand set
SWIFT_VERSIONto either 4.2 or 5.0
- Delete the Swift file created in step 2
- Delete the Bridging Header created in step 3
- In /ios
pod install --repo-update
If you have trouble, try checking out the example_objc Flutter project.
How to use
Pusher.init( ... )
|appKey||Required - The application key is a string which is globally unique to your application. It can be found in the API Access section of your application within the Channels user dashboard.|
|options||Required - The options provided to pusher, more information in the PusherOptions section.|
|enableLogging||Optional - Enabling this will activate the logging of important events to the console.|
Pusher.connect( ... )
|onConnectionStateChange||Optional - Callback when the state of the connection changes (eg. |
|onError||Optional - Callback when the connection fires an error (eg. |
Pusher.subscribe( ... )
|channelName||Required - provide the channel name to subscribe to (eg. |
Returns the current socket ID, updated after a connection change
|auth||Optional - A mechanism for authenticating a user's access to a channel at the point of subscription.|
|cluster||Optional - The identifier of the cluster your application was created in. When not supplied, will connect to the |
|host||Optional - Provide your own (websocket) host instead of the default |
|port||Optional - Provide your own (websocket) port instead of the default |
|encrypted||Optional - Tell pusher to only connect over TLS connections to ensure connection traffic is encrypted. This means using |
|activityTimeout||Optional - After this time (in milliseconds) without any messages received from the server, a ping message will be sent to check if the connection is still working. Default value is supplied by the server, low values will result in unnecessary traffic. The default is set to |
|endpoint||Required - The endpoint pusher should query to make the post request (eg. https://api.example.com/broadcating/auth).|
|headers||Optional - The headers that should be sent with the POST request to the above endpoint. 2 Different Content-Types are supported: |
This project uses code generation. Run after changing models in the project.
flutter packages pub run build_runner build --delete-conflicting-outputs