Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Android Kotlin Pusher error Start method must be called before setUserId pusher

Offen
#265 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
15/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
android, kotlin
Bereich
mobile

Rechercherichtung

The report is a Kotlin Android app calling PushNotifications.start, setUserId, close and clearAllState from the Beams SDK, and it crashes with 'Start method must be called before setUserId'. Start with the sequence in the snippet: start runs inside GlobalScope.launch, while setUserId runs only after an async view-model callback, and close and clearAllState run during logout. The work is done when the ordering problem is reproduced or explained and the reporter's flow is confirmed. The issue has two comments, no assignee and no linked pull request, and the last comment was about 994 days ago, so confirm with a maintainer that it is still wanted before starting.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

question

version pusher = "2.2.1"
version pusherNotifications = "1.6.2"
Hi,
I don´t understand this error... It only happens when I close session and call to

  PushNotifications.close()
  PushNotifications.clearAllState()

Then when go to my first Activity the app crash with the error
Pusher error Start method must be called before setUserId pusher.
But as you can see in my below code I call PushNotifications.start() first.
When the apps crash and open again, all works fine
My code
onCreate(savedInstanceState: Bundle?) {initPusher() }
initPusher is this code

        GlobalScope.launch(dispatchers.main) {
            PushNotifications.start(applicationContext, "xxxxxxx-xxx-xxxxx-xx-xxxxxx")
            viewModel.loadInfoPusherSubscribe {
                val userId = it.first
                val token = it.second
                val realToken = "Bearer "+ token
                val realURL = "https://xxxxxxxxxxx?user_id=$userId"
                val tokenProvider = BeamsTokenProvider(
                    realURL,
                    object : AuthDataGetter {
                        override fun getAuthData(): AuthData {
                            return AuthData(
                                // Headers and URL query params your auth endpoint needs to
                                // request a Beams Token for a given user
                                headers = hashMapOf( Pair("Authorization", realToken),
                                                     Pair("accept", "text/plain"),
                                                     Pair("Content-Type", "application/json-patch+json")),
                                queryParams = hashMapOf()
                            )
                        }
                    }
                )

                PushNotifications.setUserId(userId, tokenProvider,
                    object : BeamsCallback<Void, PusherCallbackError> {
                        override fun onFailure(error: PusherCallbackError) {
                            Log.e("BeamsAuth", "Could not login to Beams: ${error.message}");
                        }

                        override fun onSuccess(vararg values: Void) {
                            Log.i("BeamsAuth", "Beams login success");
                        }
                    }
                )
            }
        }
My viewModel
 suspend fun loadInfoPusherSubscribe(listener: InfoPusherListener)=
       viewModelScope.launch(dispatchers.io) {
           val profileId = async { profileDao.getProfileUser().id }
           val token =  async { session.getSessionUser().accessToken }
           withContext(dispatchers.main){
               listener.invoke(Pair(profileId.await(),token.await()))

           }

    }

What is the problem?
PushNotifications.start() is asynchronous method???

Vorherrschende Sprache
Java
Sterne
315
Forks
140
Ø Merge
11 T. 5 Std.
Gemergte PRs (30 T.)
4

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus pusher/pusher-websocket-java

Alle Issues in pusher/pusher-websocket-java

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.