Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Kotlin error when app come back from background #266

Open
AnD010 opened this issue Jun 1, 2020 · 0 comments
Open

Android Kotlin error when app come back from background #266

AnD010 opened this issue Jun 1, 2020 · 0 comments
Labels

Comments

@AnD010
Copy link

AnD010 commented Jun 1, 2020

version pusher = "2.2.1"
version pusherNotifications = "1.6.2"
Hi...I have a ugly error when app come back from background....
When I detected that the app is going to background I do this

 override fun closePrincipalChannelConnection() {
        Log.d(TAG,"closePrincipalChannelConnection")
        channel?.unbind("chat-message") {
            Log.d(TAG,"onEvent")
        }
        channel?.unbind("new-follower") {
            Log.d(TAG,"onEvent")
        }
       pusher?.unsubscribe(channelName)
    }

Then when 5-10 pass and the app come back from background, I mean, now the app is in foreground, then call

  override fun connectToGeneral(){
            channelName = "presence-$profileId"
            channel= pusher?.subscribePresence(channelName, object : PresenceChannelEventListener {
                override fun onAuthenticationFailure(message: String, e: Exception) {
                    Log.d(TAG,String.format("Authentication failure due to [%s], exception was [%s]", message, e))
                }

                override fun onSubscriptionSucceeded(channelName: String?) {
                    Log.d(TAG,"onSubscriptionSucceeded$channelName")

                }

                override fun onEvent(event: PusherEvent?) {
                    Log.d(TAG,"onEvent"+event?.data)
                }

                override fun onUsersInformationReceived(channelName: String?, users: MutableSet<User>?) {
                    Log.d(TAG, "onUsersInformationReceived$channelName${users.toString()}")
                }

                override fun userUnsubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userUnsubscribed$channelName${user.toString()}")

                }

                override fun userSubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userSubscribed$channelName${user.toString()}")
                }
            })

            channel?.bind("chat-message", object: PresenceChannelEventListener{
                override fun onAuthenticationFailure(message: String?, e: java.lang.Exception?) {
                    Log.d(TAG,String.format("Authentication failure due to [%s], exception was [%s]", message, e))

                }

                override fun onUsersInformationReceived(channelName: String?, users: MutableSet<User>?) {
                    Log.d(TAG, "onUsersInformationReceived$channelName${users.toString()}")
                }

                override fun userUnsubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userUnsubscribed$channelName${user.toString()}")

                }

                override fun userSubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userSubscribed$channelName${user.toString()}")
                }

                override fun onEvent(event: PusherEvent?) {
                    Log.d(TAG,"onEvent"+event?.data)

                    logicTypeMessage(PusherEvents.EVENT_TYPE_MESSAGE,event?.data ?:"")
                }

                override fun onSubscriptionSucceeded(channelName: String?) {
                    Log.d(TAG,"onSubscriptionSucceeded$channelName")
                }
            })

            channel?.bind("new-follower", object: PresenceChannelEventListener{
                override fun onAuthenticationFailure(message: String?, e: java.lang.Exception?) {
                    Log.d(TAG,String.format("Authentication failure due to [%s], exception was [%s]", message, e))

                }

                override fun onUsersInformationReceived(channelName: String?, users: MutableSet<User>?) {
                    Log.d(TAG, "onUsersInformationReceived$channelName${users.toString()}")
                }

                override fun userUnsubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userUnsubscribed$channelName${user.toString()}")

                }

                override fun userSubscribed(channelName: String?, user: User?) {
                    Log.d(TAG, "userSubscribed$channelName${user.toString()}")
                }

                override fun onEvent(event: PusherEvent?) {
                    Log.d(TAG,"onEvent"+event?.data)

                    logicTypeMessage(PusherEvents.EVENT_TYPE_CONNECTIONS,event?.data ?:"")

                }

                override fun onSubscriptionSucceeded(channelName: String?) {
                    Log.d(TAG,"onSubscriptionSucceeded$channelName")
                }
            })
       

    }

The app crash whit the following message

Fatal Exception: java.lang.IllegalArgumentException
Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter code
com.xxx.repository.pusher.PusherRepositoryImp$connect$1.onError (Origen desconocido:7)
com.pusher.client.connection.websocket.WebSocketConnection$5.run (WebSocketConnection.java:238)
com.pusher.client.util.Factory$1.run (Factory.java:119)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
java.lang.Thread.run (Thread.java:764)

whats wrong in my code??
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants