diff --git a/CHANGELOG.md b/CHANGELOG.md index f7658e1..556ad60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.0.4 + +* [FIXED] Dependency issue on android +* [FIXED] Compile issue on newer Kotlin versions +* [IMPROVEMENT] Updated dependencies + ## 1.0.3 * [FIXED] release build issues on android diff --git a/README.md b/README.md index 8526c0d..3ca18bc 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ This is the [Pusher Channels](https://pusher.com/channels) Flutter client. For tutorials and more in-depth information about Pusher Channels, visit our [official docs](https://pusher.com/docs/channels). ## Supported Flutter platforms + - Android through [pusher-websocket-java](https://github.com/pusher/pusher-websocket-java) - iOS through [pusher-websocket-swift](https://github.com/pusher/pusher-websocket-swift) - Web through [pusher-js](https://github.com/pusher/pusher-js) @@ -42,22 +43,22 @@ a minimal application to connect to a channel and send events. - [Web specific installation](#web-specific-installation) - [Initialization](#initialization) - [Configuration](#configuration) - - [`activityTimeout (double)`](#activitytimeout-double) - - [`apiKey (String)`](#apikey-string) - - [`authParams (Map)`](#authparams-map) - - [`authEndpoint (String)`](#authendpoint-string) - - [`cluster (String)`](#cluster-string) - - [`useTLS (bool)`](#usetls-bool) + - [`activityTimeout (double)`](#activitytimeout-double) + - [`apiKey (String)`](#apikey-string) + - [`authParams (Map)`](#authparams-map) + - [`authEndpoint (String)`](#authendpoint-string) + - [`cluster (String)`](#cluster-string) + - [`useTLS (bool)`](#usetls-bool) - [Event Callback parameters](#event-callback-parameters) - - [`onEvent`](#onevent) - - [`onSubscriptionSucceeded`](#onsubscriptionsucceeded) - - [`onSubscriptionError`](#onsubscriptionerror) - - [`onDecryptionFailure`](#ondecryptionfailure) - - [`onMemberAdded`](#onmemberadded) - - [`onMemberRemoved`](#onmemberremoved) - - [`onAuthorizer`](#onauthorizer) - - [`onConnectionStateChange`](#onconnectionstatechange) - - [`onError`](#onerror) + - [`onEvent`](#onevent) + - [`onSubscriptionSucceeded`](#onsubscriptionsucceeded) + - [`onSubscriptionError`](#onsubscriptionerror) + - [`onDecryptionFailure`](#ondecryptionfailure) + - [`onMemberAdded`](#onmemberadded) + - [`onMemberRemoved`](#onmemberremoved) + - [`onAuthorizer`](#onauthorizer) + - [`onConnectionStateChange`](#onconnectionstatechange) + - [`onError`](#onerror) - [Connection handling](#connection-handling) - [Connecting](#connecting) - [Disconnecting](#disconnecting) @@ -88,7 +89,7 @@ to add the plugin to your `pubspec.yaml`: ```yaml dependencies: - pusher_channels_flutter: "^1.0.1" + pusher_channels_flutter: '^1.0.1' ``` ### iOS specific installation @@ -116,7 +117,10 @@ index.html page: ```html - + ... ``` @@ -149,6 +153,7 @@ try { print("ERROR: $e"); } ``` + After calling `init(...)` you can connect to the Pusher servers. You can subscribe to channels before calling `connect()` @@ -159,24 +164,25 @@ describes for which platform the parameter is available: | parameter | Android | iOS | Web | | ------------------------ | ------- | --- | --- | -| activityTimeout | ✅ | ✅ | ✅ | -| apiKey | ✅ | ✅ | ✅ | -| authParam | ⬜️ | ⬜️ | ✅ | -| authEndpoint | ✅ | ✅ | ✅ | -| authTransport | ⬜️ | ⬜️ | ✅ | -| cluster | ✅ | ✅ | ✅ | -| disabledTransports | ⬜️ | ⬜️ | ✅ | -| enabledTransports | ⬜️ | ⬜️ | ✅ | -| enableStats | ⬜️ | ⬜️ | ✅ | -| ignoreNullOrigin | ⬜️ | ⬜️ | ✅ | -| logToConsole | ⬜️ | ⬜️ | ✅ | -| maxReconnectGapInSeconds | ✅ | ✅ | ⬜️ | -| maxReconnectionAttempts | ✅ | ✅ | ⬜️ | -| pongTimeout | ✅ | ✅ | ✅ | -| proxy | ✅ | ⬜️ | ⬜️ | -| useTLS | ✅ | ✅ | ⬜️ | +| activityTimeout | ✅ | ✅ | ✅ | +| apiKey | ✅ | ✅ | ✅ | +| authParam | ⬜️ | ⬜️ | ✅ | +| authEndpoint | ✅ | ✅ | ✅ | +| authTransport | ⬜️ | ⬜️ | ✅ | +| cluster | ✅ | ✅ | ✅ | +| disabledTransports | ⬜️ | ⬜️ | ✅ | +| enabledTransports | ⬜️ | ⬜️ | ✅ | +| enableStats | ⬜️ | ⬜️ | ✅ | +| ignoreNullOrigin | ⬜️ | ⬜️ | ✅ | +| logToConsole | ⬜️ | ⬜️ | ✅ | +| maxReconnectGapInSeconds | ✅ | ✅ | ⬜️ | +| maxReconnectionAttempts | ✅ | ✅ | ⬜️ | +| pongTimeout | ✅ | ✅ | ✅ | +| proxy | ✅ | ⬜️ | ⬜️ | +| useTLS | ✅ | ✅ | ⬜️ | #### `activityTimeout (double)` + After this time (in seconds) without any messages received from the server, a ping message will be sent to check if the connection is still working; the default value is supplied by the server, low values will result in unnecessary traffic. #### `apiKey (String)` @@ -230,6 +236,7 @@ https://pusher.com/docs/channels/server_api/authenticating-users/ Specifies the cluster that pusher-js should connect to. [If you'd like to see a full list of our clusters, click here](https://pusher.com/docs/clusters). If you do not specify a cluster, `mt1` will be used by default. #### `useTLS (bool)` + Whether or not you'd like to use TLS encrypted transport or not, default is `true` ## Event Callback parameters @@ -237,11 +244,13 @@ Whether or not you'd like to use TLS encrypted transport or not, default is `tru The following functions are callbacks that can be passed to the `init()` method. All are optional. #### `onEvent` + ```dart void onEvent(PusherEvent event) { print("onEvent: $event"); } ``` + Called when a event is received by the client. The global event handler will trigger on events from any channel. @@ -252,6 +261,7 @@ void onSubscriptionSucceeded(String channelName, dynamic data) { print("onSubscriptionSucceeded: $channelName data: $data"); } ``` + use this if you want to be informed of when a channel has successfully been subscribed to, which is useful if you want to perform actions that are only relevant after a subscription has succeeded. For example querying the members for presence channel. #### `onSubscriptionError` @@ -261,6 +271,7 @@ void onSubscriptionError(String message, dynamic e) { print("onSubscriptionError: $message Exception: $e"); } ``` + use this if you want to be informed of a failed subscription attempt, which you could use, for example, to then attempt another subscription or make a call to a service you use to track errors. #### `onDecryptionFailure` @@ -270,6 +281,7 @@ void onDecryptionFailure(String event, String reason) { print("onDecryptionFailure: $event reason: $reason"); } ``` + only used with private encrypted channels - use this if you want to be notified if any messages fail to decrypt. #### `onMemberAdded` @@ -294,11 +306,14 @@ Called when a member is removed to the presence channel. #### `onAuthorizer` +> :warning: Currently on web release/profile mode this doesn't work, we're still investigating this. + When passing the `onAuthorizer()` callback to the `init()` method, this callback is called to request auth information. For more information on how to generate the correct information, please look here: https://pusher.com/docs/channels/library_auth_reference/auth-signatures/ + ```dart -dynamic onAuthorizer(String channelName, String socketId, dynamic options) { +dynamic onAuthorizer(String channelName, String socketId, dynamic options) async { return { "auth": "foo:bar", "channel_data": '{"user_id": 1}', @@ -314,6 +329,7 @@ void onConnectionStateChange(dynamic currentState, dynamic previousState) { print("Connection: $currentState"); } ``` + use this if you want to use connection state changes to perform different actions / UI updates The different states that the connection can be in are: @@ -330,6 +346,7 @@ void onError(String message, int? code, dynamic e) { print("onError: $message code: $code exception: $e"); } ``` + use this if you want to be informed of errors received from Pusher Channels e.g. `Application is over connection quota`. You can find some of the possible errors listed [here](https://pusher.com/docs/channels/library_auth_reference/pusher-websockets-protocol#error-codes). ## Connection handling @@ -390,7 +407,7 @@ The shared secret used to decrypt events is loaded from the same auth endpoint r #### Limitations -* Client events are not supported on encrypted channels +- Client events are not supported on encrypted channels ```dart final privateEncryptedChannel = await pusher.subscribe(channelName: "private-encrypted-my-channel") @@ -526,7 +543,7 @@ class PusherEvent { #### Parsing event data -The `data` property of [`PusherEvent`](#pusherevent) contains the string representation of the data that you passed when you triggered the event. If you passed an object then that object will have been serialized to JSON. You can parse that JSON as appropriate. +The `data` property of [`PusherEvent`](#pusherevent) contains the string representation of the data that you passed when you triggered the event. If you passed an object then that object will have been serialized to JSON. You can parse that JSON as appropriate. ### Receiving errors @@ -555,9 +572,9 @@ await pusher.trigger(channelName: "my-channel", eventName: "client-my-event", da Events triggered by clients are called [client events](https://pusher.com/docs/channels/using_channels/events#triggering-client-events). Because they are being triggered from a client which may not be trusted there are a number of enforced rules when using them. Some of these rules include: -* Event names must have a `client-` prefix -* Rate limits -* You can only trigger an event when the subscription has succeeded +- Event names must have a `client-` prefix +- Rate limits +- You can only trigger an event when the subscription has succeeded For full details see the [client events documentation](https://pusher.com/docs/channels/using_channels/events#triggering-client-events). @@ -569,7 +586,6 @@ To get the `PusherChannel` instance from the `Pusher` instance you can use the ` final channel = pusher.getChannel("presence-channel"); ``` - ## Socket information To get information from the current socket call the `getSocketId()` method: diff --git a/android/build.gradle b/android/build.gradle index 57fea78..9a4b3ad 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -47,5 +47,5 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.pusher:pusher-java-client:2.2.8' + api 'com.pusher:pusher-java-client:2.2.8' } diff --git a/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt b/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt index 823fe2c..88fd8f9 100644 --- a/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt +++ b/android/src/main/kotlin/com/pusher/channels_flutter/PusherChannelsFlutterPlugin.kt @@ -190,13 +190,11 @@ class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAw mutex.release() } - override fun error(s: String?, s1: String?, o: Any?) { - // Log.e(TAG, "ERROR: $s $s1 $o") + override fun error(s: String, s1: String?, o: Any?) { mutex.release() } override fun notImplemented() { - // Log.e(TAG, "Not implemented") mutex.release() } }) diff --git a/example/pubspec.lock b/example/pubspec.lock index 09de044..083b431 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -99,7 +99,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" lints: dependency: transitive description: @@ -120,7 +120,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -134,7 +134,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider_linux: dependency: transitive description: @@ -183,7 +183,7 @@ packages: path: ".." relative: true source: path - version: "1.0.1" + version: "1.0.4" shared_preferences: dependency: "direct main" description: @@ -237,7 +237,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -272,7 +272,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" typed_data: dependency: transitive description: @@ -286,7 +286,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" win32: dependency: transitive description: @@ -302,5 +302,5 @@ packages: source: hosted version: "0.2.0+1" sdks: - dart: ">=2.15.0 <3.0.0" + dart: ">=2.16.0-100.0.dev <3.0.0" flutter: ">=2.5.0" diff --git a/pubspec.lock b/pubspec.lock index 1a6d40f..36076da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -78,7 +78,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" lints: dependency: transitive description: @@ -99,7 +99,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -113,7 +113,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" sky_engine: dependency: transitive description: flutter @@ -125,7 +125,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -160,7 +160,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" typed_data: dependency: transitive description: @@ -174,7 +174,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.16.0-100.0.dev <3.0.0" flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2d40bdc..df74417 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pusher_channels_flutter description: Pusher Channels Flutter Plugin -version: 1.0.3 +version: 1.0.4 homepage: https://github.com/pusher/pusher-channels-flutter repository: https://github.com/pusher/pusher-channels-flutter issue_tracker: https://github.com/pusher/pusher-channels-flutter/issues