Giter Site home page Giter Site logo

chatkit-android's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatkit-android's Issues

CurrentUser.avatarURL wrong deserialize

Hello. I use ChatManager.connect() method to recieve CurrentUser, but his avatarUrl always null. I checked server's response, and server returns correct json with avatarUrl. At class BaseSubscription after this
private val ResponseBody.messages: Sequence<Result<SubscriptionMessage<A>, Error>> get() = charStream().buffered().lineSequence() .map {line -> line.toSubscriptionMessage(messageParser) }
avatarUrl are lost.

listeners of the room don't fire after onReadCursor

Hi. I have implemented pusher chatkit on IOS and android.
On android (kotlin) I connected to chat and receive the currentUser. Setup chat listener's.
That I observe that listeners works perfectly until I use currentUser.setReadCursor function.
After this it set the cursor but chat listener's don't fire anymore :(
Witch can be the issue? Can you check this.Thanks

ChatkitTokenProvider.authData is not added to body of request

Debuging into the code, when this is called...

private fun FormBody.Builder.add(map: Map<String, String>) = {
        for ((k, v) in map) {
            add(k, v)
        }
    }

...from...

    private fun requestBody(tokenParams: Any?) = FormBody.Builder().apply {
        add("grant_type", "client_credentials")
        add(authData)
        if (tokenParams is ChatkitTokenParams) add(tokenParams.extras)
    }.build()

...it doesn't modify the FormBody

ProGuard rules missing

Am I the only one with this issue? Debug version works fine, but without proguard rules I cannot use this library in production. Can someone please help me with this?

Unable to enable push notifications

When calling

currentUser.enablePushNotifications { result ->
              when(result) {
                  is Result.Success -> Log.i("Success", "Push Notifications enabled")
                  else -> Log.e("Error", "Error starting Push Notifications")
              }
          }

As mentioned here in docs

Neither of the above messages are displayed in the log. So, basically callback function is not being called by the sdk. Please let me know if it is a bug with the sdk or I implemented it wrong.

Creating Private Rooms

I used this snippet to create a private room

val createRoomResult = currentUser.createRoom(privateRoomName,true,memberList).wait()

Turns out the room is actually not private. Is it only me, or ???

ChatListeners cannot be fired after setting a read cursor

My App has two views. The first one is a Room List View. When app user clicks one of the rooms, a Chat View will be opened. I need to monitor the changes of unReadCount on the Room List View via a ChatListeners for every room.
Everything looks fine before I set a read cursor in the Chat view. The onRoomUpdated callback on in the ChatListerner will be fired when a messaging is coming, so I can get the latest unreadCount in it. Unfortunately, after I set a Read Cursor in the Chat View, the Chatlistener won't be triggered any more. I can confirm that the Read Cursor is set successfully because the value of unReadCount is changed when I restart the app.
Thank you.

How to create new users from chatkit-android sdk?

How to create new users from chatkit-android sdk?

I am able to create new users by logging into the admin panel and creating new users manually. But I want to create a chat app, where user's can simply download my app, login via Google and the user is automatically created without anyone accessing the admin panel.

Kindly share an example that achieves this.

Some function is missing in chatkit version 1.2.0

Some functions is missing in chatkit version 1.2.0 like
var cursorResult = currentUser.getReadCursor("lobby", otherUserId)
when (cursorResult) {
is Result.Success -> /* cursorResult.value... */
}

currentUser.subscribeToRoomMultipart(
roomId = "lobby",
listeners = RoomListeners(
onNewReadCursor = { cursor ->
// e.g. toast("User ${cursor.user.name} has read up to message ${cursor.position}")
}
),
callback = { /* ... */ }
)

You can find your library code from GitHub and check that function ..You can not find because it is not available . Please make proper document after proper release of your library .

Crash when fetch/generate token

my app has been crashed when tried to get/generate a token from my server. but, it only happens in the production server, when I tested on the local server it's going to be fine. here's below my error:

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {houzcall.com.beautycall/houzcall.com.beautycall.activities.BottomNavigationActivity}: java.util.concurrent.ExecutionException: java.lang.NumberFormatException: null
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4039)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4071)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7156)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by java.util.concurrent.ExecutionException: java.lang.NumberFormatException: null
       at java.util.concurrent.FutureTask.report(FutureTask.java:123)
       at java.util.concurrent.FutureTask.get(FutureTask.java:193)
       at com.pusher.platform.subscription.TokenProvidingSubscription.b(TokenProvidingSubscription.java:8)
       at com.pusher.platform.subscription.TokenProvidingSubscription.<init>(TokenProvidingSubscription.java:50)
       at com.pusher.platform.subscription.TokenProvidingSubscriptionKt$createTokenProvidingStrategy$1.a(TokenProvidingSubscriptionKt.java:25)
       at com.pusher.platform.subscription.TokenProvidingSubscriptionKt$createTokenProvidingStrategy$1.a(TokenProvidingSubscriptionKt.java:4)
       at com.pusher.platform.subscription.ResumingSubscription$OpeningSubscriptionState.<init>(ResumingSubscription.java:137)
       at com.pusher.platform.subscription.ResumingSubscription.<init>(ResumingSubscription.java:54)
       at com.pusher.platform.subscription.ResumingSubscriptionKt$createResumingStrategy$1.a(ResumingSubscriptionKt.java:25)
       at com.pusher.platform.subscription.ResumingSubscriptionKt$createResumingStrategy$1.a(ResumingSubscriptionKt.java:4)
       at com.pusher.platform.BaseClient.a(BaseClient.java:57)
       at com.pusher.platform.Instance.a(Instance.java:45)
       at com.pusher.platform.Instance.a(Instance.java:43)
       at com.pusher.platform.Instance.a(Instance.java:71)
       at com.pusher.chatkit.PlatformClient.a(PlatformClient.java:29)
       at com.pusher.chatkit.subscription.LoggingSubscriptionKt.loggingSubscription(LoggingSubscriptionKt.java:49)
       at com.pusher.chatkit.presence.PresenceService.goOnline(PresenceService.java:81)
       at com.pusher.chatkit.presence.PresenceService.<init>(PresenceService.java:38)
       at com.pusher.chatkit.SynchronousChatManager.<init>(SynchronousChatManager.java:199)
       at com.pusher.chatkit.SynchronousChatManager.<init>(SynchronousChatManager.java:20)
       at com.pusher.chatkit.ChatManager.<init>(ChatManager.java:20)
       at houzcall.com.beautycall.core.ChatkitManager.a(ChatkitManager.java:40)
       at houzcall.com.beautycall.core.App$ApplicationLifecycleHandler.onActivityResumed(App.java:76)
       at android.app.Application.dispatchActivityResumed(Application.java:264)
       at android.app.Activity.onResume(Activity.java:1398)
       at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java)
       at houzcall.com.beautycall.activities.BottomNavigationActivity.onResume(BottomNavigationActivity.java)
       at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1416)
       at android.app.Activity.performResume(Activity.java:7612)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4031)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4071)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7156)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by java.lang.NumberFormatException: null
       at java.lang.Long.parseLong(Long.java:557)
       at java.lang.Long.parseLong(Long.java:636)
       at com.pusher.chatkit.ChatkitTokenProvider.b(ChatkitTokenProvider.java:77)
       at com.pusher.chatkit.ChatkitTokenProvider.access$getHttpUrl$p(ChatkitTokenProvider.java)
       at com.pusher.chatkit.ChatkitTokenProvider$fetchTokenFromEndpoint$1.invoke(ChatkitTokenProvider.java:69)
       at com.pusher.chatkit.ChatkitTokenProvider$fetchTokenFromEndpoint$1.invoke(ChatkitTokenProvider.java)
       at com.pusher.platform.network.FuturesKt$sam$java_util_concurrent_Callable$0.call(FuturesKt.java:2)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:764)

and this is my chatManager using production url:

chatManager = ChatManager(
                instanceLocator = "~~~~~~",
                userId = userID,
                dependencies = AndroidChatkitDependencies(
                        tokenProvider = ChatkitTokenProvider(
                                endpoint = "https://~~~.co.id/api/pusher/generate-token",
                                userId = userID
                        ),
                        context = context
                )
        )

and this is my local url:

chatManager = ChatManager(
                instanceLocator = "~~~~~~",
                userId = userID,
                dependencies = AndroidChatkitDependencies(
                        tokenProvider = ChatkitTokenProvider(
                                endpoint = "http://~~~:8000/api/pusher/generate-token",
                                userId = userID
                        ),
                        context = context
                )
        )

Android Studio V.3.6.1
Pusher chatkit-android V.1.9.0
Tested/Crashed on Android Devices API Level : 28 (Pie)

Require ACCESS_NETWORK_STATE

When I use ChatKit in a sample app, I always come across this error when the app could not connect to the internet. Even when I require the permission in my app, it still resurfaces.

2018-06-01 10:52:38.004 9218-9243/com.pusher.chatkitdemo E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.pusher.chatkitdemo, PID: 9218
    java.lang.SecurityException: ConnectivityService: Neither user 10081 nor current process has android.permission.ACCESS_NETWORK_STATE.
        at android.os.Parcel.readException(Parcel.java:2004)
        at android.os.Parcel.readException(Parcel.java:1950)
        at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:1195)
        at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:786)
        at com.pusher.platform.network.ConnectivityHelper.isConnected(ConnectivityHelper.kt:27)
        at com.pusher.platform.network.ConnectivityHelper.onConnected(ConnectivityHelper.kt:33)
        at com.pusher.platform.ErrorResolver.resolveError(ErrorResolver.kt:39)
        at com.pusher.platform.subscription.ResumingSubscription$ResumingSubscriptionState.executeSubscriptionOnce(ResumingSubscription.kt:100)
        at com.pusher.platform.subscription.ResumingSubscription$ResumingSubscriptionState.<init>(ResumingSubscription.kt:91)
        at com.pusher.platform.subscription.ResumingSubscription$OpeningSubscriptionState$3.invoke(ResumingSubscription.kt:72)
        at com.pusher.platform.subscription.ResumingSubscription$OpeningSubscriptionState$3.invoke(ResumingSubscription.kt:48)
        at com.pusher.platform.subscription.TokenProvidingSubscription$FailedSubscriptionState.<init>(TokenProvidingSubscription.kt:105)
        at com.pusher.platform.subscription.TokenProvidingSubscription$TokenProvidingState$fetchTokenAndExecuteSubscription$2.invoke(TokenProvidingSubscription.kt:86)
        at com.pusher.platform.subscription.TokenProvidingSubscription$TokenProvidingState$fetchTokenAndExecuteSubscription$2.invoke(TokenProvidingSubscription.kt:40)
        at com.pusher.chatkit.ChatkitTokenProvider$fetchTokenFromEndpoint$3.onFailure(ChatkitTokenProvider.kt:111)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:161)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)

Java Client

This sdk works for Pure Java? If not, there is a road map for it?

Can not use chatbeem library 1.4.0 with chatkit version 1.2.0 in android

Since your latest chatkit android library version is 1.2.0 and your latest chatbeem library is 1.4.0 ..I can not build grade because chatkit library also contains push notifications code ..so getting duplicate class error in grade build .even enable Pushnotification in chatkit is not working .
Please make proper library before release .For Android your documention is not matching with your latest chatkit library 1.2.0 ..

connect callback not called when listeners are added.

The connect works fine without the listeners. But once I uncomment the below code for listeners, the connect callback is never called. I tried to debug SDK code little bit, once the debugger reaches userSubscription.await() it doens't go to next step. The same works fine if there are no listeners and goes to next line and proceeds with rest of code.

        ckManager.connect(
//            listeners = ChatListeners(
//                onAddedToRoom = {room -> onCurrentUserAddedToRoom(room)}
//            ),
            callback = { result ->
                when (result) {
                    is Result.Success -> {
                        ckCurrentUser = result.value
                        ckCurrentUser.enablePushNotifications { result ->
                            when (result) {
                                is Result.Success -> {
                                    Log.d("Push Notifications", "Registered successfully")
                                }
                                is Error -> Log.e("Error", "Error starting Push Notifications")
                            }
                        }
                    }
                    is Result.Failure -> {
                        Log.d("Connection", "Can't connect to chatkit" + result.error)
                    }
                }
            }
        )

multiPart messages API not avail in 1.3.1 ; also cant send or receive messages

we had no troubles getting started with the iOS SDK which is great. however not so much luck with Android SDK.

We're on minSDKVersion 23 & targetSdkVersion 28. Android Studio 3.3.2. This is a Kotlin based Android app.

gradle entry
implementation 'com.pusher:chatkit-android:1.3.1'

Connecting is fine and works.

"currentUser" is defined as a class level var.
private lateinit var currentUser: CurrentUser

Subscribing seems to have API problems:

There a no methods available for "subscribeToRoomMultipart(...). Only "subscribeToRoom" shows up.
image

We tried the "subscribeToRoom" which compiled ok, but the error callback was returning this:-

Failed to extract required url params

This is our initialisation block:

 chatManager = ChatManager(
                instanceLocator = "v1:usxxxxxxxxxxxxxxx",
                userId = "[email protected]",
                dependencies = AndroidChatkitDependencies(
                        tokenProvider = ChatkitTokenProvider(
                                endpoint = "https://xxxxxxxxxxxxxx/token",
                                userId = "[email protected]"
                        )
                )
        )

Is something set incorrectly in the init function ?

Also just for reference following is the subscribeToRoom function:

currentUser.subscribeToRoom(
    roomId = "comps",
    listeners = RoomListeners(
            onMessage = {
                Log.i("CHAT234", "message is ${it.text}")
            },
            onMultipartMessage = {
                Log.i("CHAT234", "message sender is ${it.sender.id}")
            },
            onUserStartedTyping = {
                Log.i("CHAT234", "user started typing: ${it.id}")
            },
            onErrorOccurred = {
                Log.i("CHAT234", "ERROR is ${it.reason}")
            }

    ),
    messageLimit = 20,
    callback = {subscription ->
        Log.i("CHAT234", "subscrip callback..")
        Log.i("CHAT234", "is subscribed ? ${currentUser.isSubscribedToRoom("sogo_comps")}")

We couldn't really do much by this point so have raised this ticket. Appreciate if you can look at this.

Error Parsing Token

I created my ChatKit server with Node.js to provide a token for my app. When I test my endpoint on postman, this is my response"

{
  "status": 200,
  "headers": {},
  "body": {
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbnN0YW5jZSI6ImQ1MzBkYjE4LTIwNzMtNDdmZS04OWQxLWJhZGY0MjRmMjlhNSIsImlzcyI6ImFwaV9rZXlzLzI4NzFhMTg2LTRlMjctNDc4Zi04NTU2LTQ2NGIzZTA4NjEyZiIsImlhdCI6MTUzOTIzMzI0MCwiZXhwIjoxNTM5MzE5NjQwfQ.N9SrQOzIRNMf0acti3ENfsfzytzP2Sfm60wLG83585I",
    "expires_in": 86400,
    "token_type": "bearer"
  }
}

This presumes the server works perfectly.

However, the app throws an error:


2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err: java.util.concurrent.ExecutionException: java.lang.NumberFormatException: null
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at java.util.concurrent.FutureTask.report(FutureTask.java:94)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at java.util.concurrent.FutureTask.get(FutureTask.java:164)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.network.FlatMapFuture.get(Futures.kt:71)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.TokenProvidingSubscription.subscribe(TokenProvidingSubscription.kt:53)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.TokenProvidingSubscription.<init>(TokenProvidingSubscription.kt:43)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.TokenProvidingSubscriptionKt$createTokenProvidingStrategy$1.invoke(TokenProvidingSubscription.kt:19)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.TokenProvidingSubscriptionKt$createTokenProvidingStrategy$1.invoke(TokenProvidingSubscription.kt)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.ResumingSubscription$OpeningSubscriptionState.<init>(ResumingSubscription.kt:109)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.ResumingSubscription.<init>(ResumingSubscription.kt:39)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.ResumingSubscriptionKt$createResumingStrategy$1.invoke(ResumingSubscription.kt:18)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.subscription.ResumingSubscriptionKt$createResumingStrategy$1.invoke(ResumingSubscription.kt)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.BaseClient.subscribeResuming(BaseClient.kt:59)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.Instance.subscribeResuming(Instance.kt:72)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.Instance.subscribeResuming(Instance.kt:50)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.Instance.subscribeResuming$default(Instance.kt:49)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatManager.subscribeResuming$chatkit_core(ChatManager.kt:155)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatManager.subscribeResuming$chatkit_core$default(ChatManager.kt:154)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.users.UserSubscription.<init>(UserSubscription.kt:32)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatManager.openSubscription(ChatManager.kt:59)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatManager.connect(ChatManager.kt:55)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatManager.connect$default(ChatManager.kt:51)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.example.androidslackclone.MainActivity.connectChatKit(MainActivity.kt:76)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.example.androidslackclone.MainActivity.access$connectChatKit(MainActivity.kt:27)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.example.androidslackclone.MainActivity$getProfile$1$onSuccess$1.onSuccess(MainActivity.kt:124)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.example.androidslackclone.MainActivity$getProfile$1$onSuccess$1.onSuccess(MainActivity.kt:120)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.auth0.android.request.internal.BaseRequest.postOnSuccess(BaseRequest.java:92)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.auth0.android.request.internal.SimpleRequest.onResponse(SimpleRequest.java:76)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
2018-10-11 05:45:03.274 3199-3370/com.example.androidslackclone W/System.err:     at java.lang.Thread.run(Thread.java:761)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err: Caused by: java.lang.NumberFormatException: null
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at java.lang.Long.parseLong(Long.java:406)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at java.lang.Long.parseLong(Long.java:485)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatkitTokenProvider.parseTokenResponse(ChatkitTokenProvider.kt:87)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatkitTokenProvider.access$parseTokenResponse(ChatkitTokenProvider.kt:23)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatkitTokenProvider$fetchTokenFromEndpoint$1$1.invoke(ChatkitTokenProvider.kt:54)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.chatkit.ChatkitTokenProvider$fetchTokenFromEndpoint$1$1.invoke(ChatkitTokenProvider.kt:23)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at com.pusher.platform.network.FuturesKt$sam$java_util_concurrent_Callable$0.call(Futures.kt)
2018-10-11 05:45:03.275 3199-3370/com.example.androidslackclone W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)

My understanding of this is that it is seeing the expires_in value as null. This could be as a result of wrong parsing.

Please, can you look into it asap?

Expose some UserSubscriptionListener functions

Functions such as userJoined, userLeft , userIsTyping prove very helpful when building an interactive chat application especially when you show such extra details in the chat activity. Here in chatkit, such functions are only exposed in the UserSubscriptionsAdapter which we only get when the chatManager is connected. Definitely, we can't keep connecting the chatManager in any activity where we need it.

I therefore propose, we have another interface that exposes such functions and then we can listen to them through the CurrentUser .

app is crashing while fetching more messages.

java.lang.ArrayIndexOutOfBoundsException: length=10; index=10
                                                 at java.util.ArrayList.add(ArrayList.java:468)
                                                 at com.pusher.chatkit.ChatManager.subscribeResuming$chatkit_core(ChatManager.kt:160)
                                                 at com.pusher.chatkit.cursors.CursorService.createSubscription(CursorService.kt:72)
                                                 at com.pusher.chatkit.cursors.CursorService.subscribeForRoom(CursorService.kt:64)
                                                 at com.pusher.chatkit.rooms.RoomSubscription.<init>(RoomSubscription.kt:42)
                                                 at com.pusher.chatkit.rooms.RoomService.subscribeToRoom(RoomService.kt:79)
                                                 at com.pusher.chatkit.CurrentUser.subscribeToRoom(CurrentUser.kt:139)
                                                 at com.pusher.chatkit.CurrentUser.subscribeToRoom(CurrentUser.kt:123)
                                                 at wellthy.care.pusher.ApiPusherChatActivity$bind$1.doResume(ApiPusherChatActivity.kt:263)
                                                 at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
                                                 at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161)
                                                 at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:25)
                                                 at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1412)
                                                 at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:285)
                                                 at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1152)
                                                 at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1990)
                                                 at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1938)
                                                 at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Could't find any listener for setReadCursor

These are the only two functions inside com.pusher.chatkit.CurrentUser that use Futures.schedule. Why?

fun setReadCursor(room: Room, position: Int) {
      Futures.schedule { syncCurrentUser.setReadCursor(room.id, position) }
  }

  fun setReadCursor(roomId: String, position: Int) {
      Futures.schedule { syncCurrentUser.setReadCursor(roomId, position) }
  }

Documentation seems outdated

Hey guys,

This is what is there in the documentation to connect.

const val INSTANCE_LOCATOR = "v1:us1:80215247-1df3-4956-8ba8-9744ffd12161"
const val TOKEN_PROVIDER_ENDPOINT = "your.auth.url"
const val USER_ID = "sarah"

val chatManager = ChatManager(
instanceLocator = INSTANCE_LOCATOR,
userId = USER_ID,
dependencies = AndroidChatkitDependencies(
context = getApplicationContext(),
tokenProvider = ChatkitTokenProvider(TOKEN_PROVIDER_ENDPOINT, USER_ID)
)
)

But, it seems like ChatkitTokenProvider is expecting USER_ID as a map.

Best,
Kanoshka

Wrong error when get undefined read cursor

I'm trying to get read cursor for some user for some roomId, which hasn't been previously set. And I'm receiveing error (Must be subscribed to room some_id to access member's read cursors) even if I have previously checked for room subscription. Is it not better to just return null in that case? Or I'm doing something wrong?
Caused by: OtherError(reason=Must be subscribed to room some_id to access member's read cursors, exception=null) at elements.Errors.other(errors.kt:42) at com.pusher.chatkit.cursors.CursorService.notSubscribedToRoom(CursorService.kt:66) at com.pusher.chatkit.cursors.CursorService.getReadCursor(CursorService.kt:63) at com.pusher.chatkit.SynchronousCurrentUser.getReadCursor(SynchronousCurrentUser.kt:56) at com.pusher.chatkit.CurrentUser.getReadCursor(CurrentUser.kt:61)

D/ChatRoomsActivity: error.reason: Room membership required

Hello, I'm trying to integrate Chatkit into my android app however I'm running into issues with a user who is already a member of the room, cannot subscribe to a room and am getting the error: D/ChatRoomsActivity:error.reason: Room membership required

The issue is also here on StackOverflow

This happens at the ChatRoomActivity once a room as been clicked on from the ChatRoomListActivity

Here is the code block being used:

currentUser.subscribeToRoomMultipart(
                roomId = roomId,
                listeners = RoomListeners(
                        onMultipartMessage = { message ->
                            Log.d("TAG",message.toString())
                            runOnUiThread(Runnable{
                                adapter.addMessage(message)
                                recycler_view.layoutManager?.scrollToPosition(adapter.itemCount -1)
                            })
                        },
                        onErrorOccurred = { error ->
                            Log.d(AppActivityTags.chatRoomActivityTAG, "error.reason: " + error.reason)
                        }
                ),
                messageLimit = 100, // Optional
                callback = { subscription ->
                    // Called when the subscription has started.
                    // You should terminate the subscription with subscription.unsubscribe()
                    // when it is no longer needed
                }
        )

username is: username2-PCKid
here is a snippet of dashboard:
Also, although it says Room membership required, I am somehow still able to add messages to the room? That is misleading.

Screen Shot 2020-01-16 at 9 04 33 PM

Screen Shot 2020-01-16 at 10 14 17 PM

Any and all help is appreciated!

app is crashing when i try to login?

Caused by java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: com.pusher.chatkit.ChatkitTokenProvider$add$1
at java.util.concurrent.FutureTask.report(FutureTask.java:94)
at java.util.concurrent.FutureTask.get(FutureTask.java:164)
at com.pusher.platform.network.FlatMapFuture.get(Futures.kt:71)
at com.pusher.platform.subscription.TokenProvidingSubscription.subscribe(TokenProvidingSubscription.kt:53)
at com.pusher.platform.subscription.TokenProvidingSubscription.(TokenProvidingSubscription.kt:43)
at com.pusher.platform.subscription.TokenProvidingSubscriptionKt$createTokenProvidingStrategy$1.invoke(TokenProvidingSubscription.kt:19)
at com.pusher.platform.subscription.TokenProvidingSubscriptionKt$createTokenProvidingStrategy$1.invoke(TokenProvidingSubscription.kt)
at com.pusher.platform.subscription.ResumingSubscription$OpeningSubscriptionState.(ResumingSubscription.kt:109)
at com.pusher.platform.subscription.ResumingSubscription.(ResumingSubscription.kt:39)
at com.pusher.platform.subscription.ResumingSubscriptionKt$createResumingStrategy$1.invoke(ResumingSubscription.kt:18)
at com.pusher.platform.subscription.ResumingSubscriptionKt$createResumingStrategy$1.invoke(ResumingSubscription.kt)
at com.pusher.platform.BaseClient.subscribeResuming(BaseClient.kt:59)
at com.pusher.platform.Instance.subscribeResuming(Instance.kt:72)
at com.pusher.platform.Instance.subscribeResuming(Instance.kt:50)
at com.pusher.platform.Instance.subscribeResuming$default(Instance.kt:49)
at com.pusher.chatkit.ChatManager.subscribeResuming$chatkit_core(ChatManager.kt:155)
at com.pusher.chatkit.ChatManager.subscribeResuming$chatkit_core$default(ChatManager.kt:154)
at com.pusher.chatkit.users.UserSubscription.(UserSubscription.kt:32)
at com.pusher.chatkit.ChatManager.openSubscription(ChatManager.kt:59)
at com.pusher.chatkit.ChatManager.connect(ChatManager.kt:55)
at com.pusher.chatkit.ChatManager.connect(ChatManager.kt:86)
at wellthy.care.pusher.PusherChat.connect(PusherChat.kt:94)
at wellthy.care.feature.onboarding.phone.PhoneVerificationActivity$navigateUserToMainFlow$1.onComplete(PhoneVerificationActivity.kt:234)
at com.google.android.gms.tasks.zzf.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Room subscription for new message is not working

Hi,
When I have chat between two clients, I can get only the first new message, after that all other new messages are not coming to the target client,

my code:

   subscription = ChatkitManager.getInstance().getUserManager().subscribeToRoom(roomID, new Function1<RoomSubscriptionEvent, Unit>() {
           @Override
           public Unit invoke(final RoomSubscriptionEvent roomSubscriptionEvent) {

               if(roomSubscriptionEvent instanceof RoomSubscriptionEvent.NewMessage){
                         //handle message
                }

s3 links lead to an error

(URL(message.attachment.link).query?.split("&") ?: emptyList()) leads to an error like s3:// malformed URL when fetching messages

Editing a message

Are there plans to support editing of messages in future? Or can I just submit a PR for that?

Unable to run the project

Cloned the repo and it doesn't even build. I get this error:
Gradle sync failed: 'Gradle: net.bytebuddy:byte-buddy-agent:1.7.4@jar' already disposed

Any help fixing it? Thanks!

Issue with adding chatkit dependecy to gradle

i add the dependency as explained in the ReadMe
my gradle keeps crashing and i keep getting the same errors
it seems to search everywhere including the maven repositories but cant find the files

Error:Could not resolve all files for configuration ':app:debugCompileClasspath'.

Could not find com.pusher:chatkit-android:$chatkit-version.
Searched in the following locations:
file:/opt/google/android-sdk/extras/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.pom
file:/opt/google/android-sdk/extras/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.jar
file:/opt/google/android-sdk/extras/google/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.pom
file:/opt/google/android-sdk/extras/google/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.jar
file:/opt/google/android-sdk/extras/android/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.pom
file:/opt/google/android-sdk/extras/android/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.jar
file:/opt/google/android-studio/gradle/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.pom
file:/opt/google/android-studio/gradle/m2repository/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.jar
https://dl.google.com/dl/android/maven2/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.pom
https://dl.google.com/dl/android/maven2/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.jar
https://jcenter.bintray.com/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.pom
https://jcenter.bintray.com/com/pusher/chatkit-android/$chatkit-version/chatkit-android-$chatkit-version.jar
Required by:
project :app

These are my dependencies:
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:27.1.1'
compile 'com.android.support:gridlayout-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
implementation 'com.pusher:chatkit-android:$chatkit-version'
}

Is chat UI part of the this SDK?

UI features like

  1. one-to-one chat screen,
  2. group-chat screen,
  3. creating a new group etc.

Are these features part of the chat kit or do we need to build these features on our own?

RoomListeners onPresenceChange retrieve same user not others

In chatkit-swift on first subscription to room listeners by default it will retrieve the other users in the room (disregarding the currentUser) however in chatkit-android when i subscribe the onPresenceChange callback throws the same user (currentUser) who is the subscriber. I should receive the other users in this case.

Here is a snippet for my code

currentUser?.subscribeToRoomMultipart( roomId, RoomListeners( onPresenceChange = { user -> // >>>>>> here i receive same user that i am already subscribing with :: i expect to receive the other users } ), messageLimit = 0, callback = { subscription -> disposableSubscription.add(subscription) })

In case that this is intended behaviour, can u please tell alternative way to get the other users on onPresenceChange or chat subscription ?

the documents are not matching with version id?

currentUser.fetchMessages(
room = someRoom,
initialId = 42, // Optional
direction = NEWER_FIRST, // Optional, OLDER_FIRST by default
limit = 20 // Optional, 10 by default
).wait().let { result ->
when(result) { // Result<List, Error>
is Result.Success -> toast("Mesages ${result.value} received.")
is Result.Failure -> toast("Oops, something bad happened: ${result.error}")
}
}

i was trying to use Fetch Messages , it was not showing the latest build 0.10.0. can you please update the version?

fetch messages have random behaviour

when i try to fetch first time i use this fuction

fetchMessages(roomId=roomId,direction = Direction.ORDER_FIRST,limit = 20)
and i am listing the id here
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532585 and text fourty
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532584 and text thity nine
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532581 and text thirty six
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532577 and text thirty five
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532575 and text 34
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532574 and text 33
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532573 and text 32
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532571 and text 31
05-16 18:32:02.778 26511-27514/1g 1: message item id first time: 1532569 and text 30
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532568 and text 29
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532567 and text 28
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532566 and text 27
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532563 and text 26
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532562 and text 25
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532561 and text 24
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532560 and text 23
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532559 and text 22
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532558 and text 21
05-16 18:32:02.779 26511-27514/g 1: message item id first time: 1532557 and text 20
05-16 18:32:02.779 26511-27514/1g 1: message item id first time: 1532556 and text 19

and next time i am trying to fetch i am using this
fetchMessages(roomId=room!!.id,initialId = messageItemlast.id,direction = Direction.NEWER_FIRST,limit = 20)

05-16 18:42:54.218 32350-32350/1 id for loop inside load more : 1532514 and text vhj
05-16 18:42:54.218 32350-32350/1 id for loop inside load more : 1532535 and text second
05-16 18:42:54.218 32350-32350/1 id for loop inside load more : 1532536 and text third
05-16 18:42:54.218 32350-32350/1 id for loop inside load more : 1532537 and text fourth
05-16 18:42:54.219 32350-32350/1 id for loop inside load more : 1532538 and text fifith
05-16 18:42:54.219 32350-32350/1 id for loop inside load more : 1532539 and text second
05-16 18:42:54.219 32350-32350/1 id for loop inside load more : 1532542 and text seventh
05-16 18:42:54.219 32350-32350/1 id for loop inside load more : 1532543 and text eight
05-16 18:42:54.219 32350-32350/1 id for loop inside load more : 1532544 and text nine
05-16 18:42:54.220 32350-32350/1 id for loop inside load more : 1532545 and text ten
05-16 18:42:54.220 32350-32350/1 id for loop inside load more : 1532546 and text 11
05-16 18:42:54.220 32350-32350/1 id for loop inside load more : 1532547 and text 12
05-16 18:42:54.220 32350-32350/1 id for loop inside load more : 1532548 and text thirteen
05-16 18:42:54.220 32350-32350/1 id for loop inside load more : 1532549 and text fourteen
05-16 18:42:54.220 32350-32350/1 id for loop inside load more : 1532550 and text fifteen
05-16 18:42:54.221 32350-32350/1 id for loop inside load more : 1532551 and text sixteen
05-16 18:42:54.221 32350-32350/1 id for loop inside load more : 1532553 and text 17
05-16 18:42:54.221 32350-32350/1 id for loop inside load more : 1532555 and text 18
05-16 18:42:54.221 32350-32350/1 id for loop inside load more : 1532556 and text 19
05-16 18:42:54.221 32350-32350/1 id for loop inside load more : 1532557 and text 20

as you could see the message id 1532557,1532556 should not be fetched..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.