1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()
//                }
            }
        }
    }
}