You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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???
The text was updated successfully, but these errors were encountered:
AnD010
changed the title
Pusher error Start method must be called before setUserId pusher
Android Kotlin Pusher error Start method must be called before setUserId pusher
Jun 1, 2020
You probably just want to call stop() yourself, and then start() later.
I can't reproduce your issue with stopping and starting the library with a button press in a simple Activity - perhaps you could try extracting that logic out of the coroutine and seeing if the issue still persists?
Hi,
I don´t understand this error... It only happens when I close session and call to
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
What is the problem?
PushNotifications.start() is asynchronous method???
The text was updated successfully, but these errors were encountered: