package com.xty.common

import android.content.Context
import cn.jpush.android.api.JPushInterface

/**
 *
 * Description: JPush工具类
 *
 */
class JPushHelper (var context: Context) {
    //根据用户设置开启或关闭JPush
    fun stopOrResumeJPush(flag : Boolean){
        if (flag) resumeJPush() else stopJPush()
    }
    //停止JPush服务
    fun stopJPush(){
        if (!isJPushStop()) JPushInterface.stopPush(context);
    }
    //开启JPush服务
    fun resumeJPush(){
        if (isJPushStop()) JPushInterface.resumePush(context)
    }
    //检查JPush服务是否启动
    fun isJPushStop(): Boolean{
        return JPushInterface.isPushStopped(context)
    }
}