Unverified Commit a436dc0e authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge branch 'develop-2.x' into new/insert-username

parents 2e8a0993 30b3b8b0
...@@ -13,8 +13,8 @@ android { ...@@ -13,8 +13,8 @@ android {
applicationId "chat.rocket.android" applicationId "chat.rocket.android"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion versions.targetSdk targetSdkVersion versions.targetSdk
versionCode 2001 versionCode 2002
versionName "2.0.0-beta1" versionName "2.0.0-beta2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
} }
......
...@@ -144,7 +144,8 @@ class MainPresenter @Inject constructor( ...@@ -144,7 +144,8 @@ class MainPresenter @Inject constructor(
suspend fun refreshToken(token: String?) { suspend fun refreshToken(token: String?) {
token?.let { token?.let {
client.registerPushToken(it, getAccountsInteractor.get(), factory) localRepository.save(LocalRepository.KEY_PUSH_TOKEN, token)
client.registerPushToken(token, getAccountsInteractor.get(), factory)
} }
} }
} }
\ No newline at end of file
...@@ -49,9 +49,13 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -49,9 +49,13 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
launch(CommonPool) { launch(CommonPool) {
val token = InstanceID.getInstance(this@MainActivity).getToken(getString(R.string.gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null) try {
Timber.d("GCM token: $token") val token = InstanceID.getInstance(this@MainActivity).getToken(getString(R.string.gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null)
presenter.refreshToken(token) Timber.d("GCM token: $token")
presenter.refreshToken(token)
} catch (ex: Exception) {
Timber.d(ex, "Missing play services...")
}
} }
presenter.connect() presenter.connect()
......
...@@ -35,17 +35,19 @@ class FirebaseTokenService : FirebaseInstanceIdService() { ...@@ -35,17 +35,19 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
// default push gateway. We should register this project's own project sender id into it. // default push gateway. We should register this project's own project sender id into it.
val gcmToken = InstanceID.getInstance(this) val gcmToken = InstanceID.getInstance(this)
.getToken(getString(R.string.gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null) .getToken(getString(R.string.gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null)
val currentServer = getCurrentServerInteractor.get()!! val currentServer = getCurrentServerInteractor.get()
val client = factory.create(currentServer) val client = currentServer?.let { factory.create(currentServer) }
gcmToken?.let { gcmToken?.let {
localRepository.save(LocalRepository.KEY_PUSH_TOKEN, gcmToken) localRepository.save(LocalRepository.KEY_PUSH_TOKEN, gcmToken)
launch { client?.let {
try { launch {
Timber.d("Registering push token: $gcmToken for ${client.url}") try {
client.registerPushToken(gcmToken) Timber.d("Registering push token: $gcmToken for ${client.url}")
} catch (ex: RocketChatException) { client.registerPushToken(gcmToken)
Timber.e(ex) } catch (ex: RocketChatException) {
Timber.e(ex)
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment