package cn.flightfeather.thirdappmodule.util.push
|
|
import android.content.Context
|
import android.content.SharedPreferences
|
/**
|
* @author riku
|
* Date: 2019/12/26
|
*/
|
object LoginInitializer {
|
|
/**
|
* 根据登录状态绑定推送
|
*/
|
fun onLoginStatusCheck(context: Context?, isLogin: Boolean, accountName: String) {
|
if (context==null) return
|
//读取登录用户信息
|
val sharedPre: SharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE)
|
val isBindAccount = sharedPre.getBoolean("isBindAccount", false)
|
|
if (isLogin) {
|
if (!isBindAccount) {
|
PushService.bindAccount(accountName) {
|
sharedPre.edit().putBoolean("isBindAccount", true).apply()
|
}
|
}
|
} else {
|
if (isBindAccount) {
|
PushService.unBindAccount {
|
sharedPre.edit().putBoolean("isBindAccount", false).apply()
|
}
|
}
|
}
|
}
|
}
|