From b43efa146e0244016ad05ab36051719ccbd16b2d Mon Sep 17 00:00:00 2001 From: archurtan Date: Fri, 18 Sep 2020 17:29:27 +0800 Subject: [PATCH] =?UTF-8?q?Firebase=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idf1a2b885cf62bcdbce46f5f937bcecb3012c59f --- .../iot/explorer/link/kitlink/activity/LoginActivity.kt | 5 +++++ .../iot/explorer/link/kitlink/activity/MainActivity.kt | 2 ++ .../iot/explorer/link/core/demo/activity/LoginActivity.kt | 2 ++ 3 files changed, 9 insertions(+) diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LoginActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LoginActivity.kt index 25d0a3db9..a5cffc34a 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LoginActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LoginActivity.kt @@ -5,6 +5,7 @@ import android.content.Intent import android.text.TextUtils import android.view.LayoutInflater import android.view.View +import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.crashlytics.FirebaseCrashlytics import com.tencent.iot.explorer.link.App import com.tencent.iot.explorer.link.ErrorCode @@ -39,6 +40,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin private lateinit var accoutPasswdLoginView: View private lateinit var verifyCodeLoginView: View + private var mFirebaseAnalytics: FirebaseAnalytics? = null private var fromTag = "" private var accountType = false //true为手机号,false为邮箱 private var accountForAutoFill = "" @@ -76,6 +78,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin intent.getStringExtra("from")?.let { fromTag = it } + mFirebaseAnalytics = FirebaseAnalytics.getInstance(this@LoginActivity) presenter = LoginPresenter(this) iv_back.setColorFilter(resources.getColor(R.color.black_333333)) tv_title.text = getString(R.string.verify_code_login) @@ -84,6 +87,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin if (!TextUtils.isEmpty(App.data.getToken())) { val userId = SharePreferenceUtil.getString(this@LoginActivity, App.CONFIG, CommonField.USER_ID) FirebaseCrashlytics.getInstance().setUserId(userId) + mFirebaseAnalytics!!.setUserId(userId) startActivity(Intent(this, MainActivity::class.java)) finish() return @@ -240,6 +244,7 @@ class LoginActivity : PActivity(), LoginView, View.OnClickListener, WeChatLogin App.data.userInfo = this SharePreferenceUtil.saveString(this@LoginActivity, App.CONFIG, CommonField.USER_ID, App.data.userInfo.UserID) FirebaseCrashlytics.getInstance().setUserId(App.data.userInfo.UserID) + mFirebaseAnalytics?.setUserId(App.data.userInfo.UserID) saveUser(user) T.show(getString(R.string.login_success)) if (TextUtils.isEmpty(fromTag)) { diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/MainActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/MainActivity.kt index a34c82cfd..811ed987c 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/MainActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/MainActivity.kt @@ -8,6 +8,7 @@ import android.text.TextUtils import android.view.View import androidx.fragment.app.Fragment import com.alibaba.fastjson.JSONObject +import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.crashlytics.FirebaseCrashlytics import com.tencent.iot.explorer.link.App import com.tencent.iot.explorer.link.R @@ -110,6 +111,7 @@ class MainActivity : PActivity(), MyCallback { override fun initView() { val userId = SharePreferenceUtil.getString(this@MainActivity, App.CONFIG, CommonField.USER_ID) FirebaseCrashlytics.getInstance().setUserId(userId) + FirebaseAnalytics.getInstance(this).setUserId(userId) openXGPush() home_bottom_view.addMenu( BottomItemEntity( diff --git a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/core/demo/activity/LoginActivity.kt b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/core/demo/activity/LoginActivity.kt index 0368d00eb..7061b2960 100644 --- a/sdkdemo/src/main/java/com/tencent/iot/explorer/link/core/demo/activity/LoginActivity.kt +++ b/sdkdemo/src/main/java/com/tencent/iot/explorer/link/core/demo/activity/LoginActivity.kt @@ -2,6 +2,7 @@ package com.tencent.iot.explorer.link.core.demo.activity import android.text.TextUtils import android.widget.Toast +import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.crashlytics.FirebaseCrashlytics import com.tencent.iot.explorer.link.core.auth.IoTAuth import com.tencent.iot.explorer.link.core.auth.callback.LoginCallback @@ -69,6 +70,7 @@ class LoginActivity : BaseActivity(), LoginCallback { response.parse(UserInfoResponse::class.java)?.Data?.run { App.data.userInfo = this FirebaseCrashlytics.getInstance().setUserId(App.data.userInfo.UserID) + FirebaseAnalytics.getInstance(this@LoginActivity).setUserId(App.data.userInfo.UserID) jumpActivity(MainActivity::class.java, true) } }