Skip to content

Commit

Permalink
Add subscription count (#75)
Browse files Browse the repository at this point in the history
* - replace deprecations
- update android dependencies

* add subscription count event

* use latest pusher-java-client 2+
use latest Gson 2+

* add subscription count event for ios
update pub dependencies
format with swiftformat

* fix socket_id

* move underscore to end of local varname

* move event names to pusher_internal:.. to pusher:... events
also send the public pusher:.. invents to the clients.

Co-authored-by: Niek <[email protected]>
Co-authored-by: niek <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2022
1 parent 9f606ac commit 4cff17d
Show file tree
Hide file tree
Showing 22 changed files with 580 additions and 516 deletions.
7 changes: 4 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'com.pusher'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down Expand Up @@ -47,5 +47,6 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api 'com.pusher:pusher-java-client:2.2.8'
api 'com.pusher:pusher-java-client:2.+'
api 'com.google.code.gson:gson:2.+'
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.pusher.channels_flutter

import com.google.gson.Gson
import com.pusher.client.Authorizer
import com.pusher.client.ChannelAuthorizer
import com.pusher.client.Pusher
import com.pusher.client.PusherOptions
import com.pusher.client.channel.*
import com.pusher.client.connection.ConnectionEventListener
import com.pusher.client.connection.ConnectionState
import com.pusher.client.connection.ConnectionStateChange
import com.pusher.client.util.HttpAuthorizer
import com.pusher.client.util.HttpChannelAuthorizer
import io.flutter.Log
import android.app.Activity
import io.flutter.embedding.engine.plugins.FlutterPlugin
Expand All @@ -25,7 +25,7 @@ import java.util.concurrent.Semaphore
class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
ConnectionEventListener, ChannelEventListener, SubscriptionEventListener,
PrivateChannelEventListener, PrivateEncryptedChannelEventListener, PresenceChannelEventListener,
Authorizer {
ChannelAuthorizer {
private var activity: Activity? = null
private lateinit var methodChannel: MethodChannel
private var pusher: Pusher? = null
Expand All @@ -41,11 +41,11 @@ class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAw
}

override fun onAttachedToActivity(binding: ActivityPluginBinding) {
activity = binding.activity as Activity
activity = binding.activity
}

override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
activity = binding.activity as Activity
activity = binding.activity
}

override fun onDetachedFromActivityForConfigChanges() {
Expand Down Expand Up @@ -110,9 +110,9 @@ class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAw
call.argument("maxReconnectionAttempts")!!
if (call.argument<Int>("maxReconnectGapInSeconds") != null) options.maxReconnectGapInSeconds =
call.argument("maxReconnectGapInSeconds")!!
if (call.argument<String>("authEndpoint") != null) options.authorizer =
HttpAuthorizer(call.argument("authEndpoint"))
if (call.argument<String>("authorizer") != null) options.authorizer = this
if (call.argument<String>("authEndpoint") != null) options.channelAuthorizer =
HttpChannelAuthorizer(call.argument("authEndpoint"))
if (call.argument<String>("authorizer") != null) options.channelAuthorizer = this
if (call.argument<String>("proxy") != null) {
val (host, port) = call.argument<String>("proxy")!!.split(':')
options.proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(host, port.toInt()))
Expand Down Expand Up @@ -220,7 +220,7 @@ class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAw
callback(
"onEvent", mapOf(
"channelName" to channelName,
"eventName" to "pusher_internal:subscription_succeeded",
"eventName" to "pusher:subscription_succeeded",
"data" to emptyMap<String,String>()
)
)
Expand Down Expand Up @@ -268,7 +268,7 @@ class PusherChannelsFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAw
callback(
"onEvent", mapOf(
"channelName" to channelName,
"eventName" to "pusher_internal:subscription_succeeded",
"eventName" to "pusher:subscription_succeeded",
"userId" to channel.me.id,
"data" to data
)
Expand Down
4 changes: 1 addition & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.pusher.channels_flutter_example"
minSdkVersion 16
targetSdkVersion 31
Expand All @@ -57,7 +56,7 @@ android {
signingConfig signingConfigs.debug
}
}
buildToolsVersion '30.0.3'
buildToolsVersion '33.0.0'
}

flutter {
Expand All @@ -66,5 +65,4 @@ flutter {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.pusher:pusher-java-client:2.2.8'
}
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
12 changes: 6 additions & 6 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
#Tue Sep 20 09:27:18 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
24 changes: 12 additions & 12 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ PODS:
- NWWebSocket (0.5.2)
- pusher_channels_flutter (0.0.1):
- Flutter
- PusherSwift (~> 10.0.0)
- PusherSwift (10.0.0):
- PusherSwift (~> 10.1.1)
- PusherSwift (10.1.1):
- NWWebSocket (~> 0.5.2)
- TweetNacl (~> 1.0.0)
- shared_preferences (0.0.1):
- shared_preferences_ios (0.0.1):
- Flutter
- TweetNacl (1.0.2)

DEPENDENCIES:
- Flutter (from `Flutter`)
- pusher_channels_flutter (from `.symlinks/plugins/pusher_channels_flutter/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)

SPEC REPOS:
trunk:
Expand All @@ -27,17 +27,17 @@ EXTERNAL SOURCES:
:path: Flutter
pusher_channels_flutter:
:path: ".symlinks/plugins/pusher_channels_flutter/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios"

SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
NWWebSocket: 21f0c73639815da3272862c912275b26102aa80c
pusher_channels_flutter: 36d51ae4a94195bb9109c2009de2f8445e222d67
PusherSwift: 264eaceb921a5f8e166f01a2242371179540c7ff
shared_preferences: 5033afbb22d372e15aff8ff766df9021b845f273
pusher_channels_flutter: bf646336659d2cc058c62346b4b9e8b82e37b71b
PusherSwift: 70a805a950ab49381e164c54ac19c3b9c1d288e3
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
TweetNacl: 3abf4d1d2082b0114e7a67410e300892448951e6

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.2
COCOAPODS: 1.11.3
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading

0 comments on commit 4cff17d

Please sign in to comment.