Commit e6018d77 authored by wanglei's avatar wanglei

...

parent 1a8ac8c1
......@@ -21,7 +21,9 @@ object PushManager {
*/
fun newUserPush(newUserAvoidTime: Int): Boolean {
val firstLaunchTime = FileApp.fContext.queryDataStoreBlock(FIRST_LAUNCH_TIME_KEY, 0L)
val flag = (System.currentTimeMillis() - firstLaunchTime) / 1000 > newUserAvoidTime
val haveFirstLaunchTime = (System.currentTimeMillis() - firstLaunchTime) / 1000
LogEx.logDebug(TAG, "haveFirstLaunchTime=$haveFirstLaunchTime newUserAvoidTime=$newUserAvoidTime")
val flag = haveFirstLaunchTime > newUserAvoidTime
return flag
}
......@@ -31,7 +33,9 @@ object PushManager {
*/
fun canPushNextTime(interval: Int): Boolean {
val lastPushTime = FileApp.fContext.queryDataStoreBlock(ALL_LAST_PUSH_TIME, 0)
return (System.currentTimeMillis() - lastPushTime) / 1000 > interval
val haveInterval = (System.currentTimeMillis() - lastPushTime) / 1000
LogEx.logDebug(TAG, "haveInterval=$haveInterval interval=$interval")
return haveInterval > interval
}
/**
......@@ -43,17 +47,15 @@ object PushManager {
val pushManagement = ComUtils.getPushConfig()
// 新用户是否显示
val newUserAvoidFlag = newUserPush(pushManagement.newuser_avoid_time)
val newUserLog = "新用户推送 newuser_avoid_time=${pushManagement.newuser_avoid_time} newUserFlag=$newUserAvoidFlag"
LogEx.logDebug(TAG, newUserLog)
if (!newUserAvoidFlag) {
EventHelper.event("pushCircleOrder_isPush", newUserLog, eventParams = eventParams)
if (!newUserPush(pushManagement.newuser_avoid_time)) {
LogEx.logDebug(TAG, "================================新用户推送拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "新用户推送拦截", eventParams = eventParams)
return false
}
// 渠道用户是否推送
if (!UserChancelEx.getUserChancelSwitch(pushManagement.push_show)) {
LogEx.logDebug(TAG, "渠道用户不推送")
LogEx.logDebug(TAG, "================================渠道用户拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "渠道用户不推送", eventParams = eventParams)
return false
}
......@@ -61,41 +63,33 @@ object PushManager {
//是否上次推送间隔大于配置间隔
val isOganic = UserChancelEx.isOrganicUser()
val interval = if (isOganic) pushManagement.o_push_interval else pushManagement.all_push_interval
val intervalFlog = canPushNextTime(interval)
val intervalLog = "推送总间隔推送 interval=$interval intervalFlog=$intervalFlog"
LogEx.logDebug(TAG, intervalLog)
if (!intervalFlog) {
EventHelper.event("pushCircleOrder_isPush", intervalLog, eventParams = eventParams)
if (!canPushNextTime(interval)) {
LogEx.logDebug(TAG, "================================总间隔拦截===============================")
return false
}
//当前类型通知推送间隔是否大于配置间隔
val pushCfg: PushCfg? = ComUtils.getPushTypeData(actionId.toString())
val pushInterval = pushCfg?.push_interval ?: 0
val actionIdIntervalFlag = actionTypeCanPsh(actionId)
val log = "当前通知类型间隔推送 actionId=$actionId pushInterval=$pushInterval actionIdIntervalFlag=$actionIdIntervalFlag"
LogEx.logDebug(TAG, log)
if (!actionIdIntervalFlag) {
EventHelper.event("pushCircleOrder_isPush", log, eventParams = eventParams)
if (!actionTypeCanPsh(actionId)) {
LogEx.logDebug(TAG, "================================当前通知类型间隔拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "当前通知类型间隔拦截", eventParams = eventParams)
return false
}
//是否在前台推送
if (AppUtils.isAppForeground()) {
LogEx.logDebug(TAG, "app在前台不推送")
EventHelper.event("pushCircleOrder_isPush", "app在前台不推送", eventParams = eventParams)
LogEx.logDebug(TAG, "================================app在前台拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "app在前台拦截", eventParams = eventParams)
return false
}
//进程是否是活的
if (!TextUtils.isEmpty(JinChengCheck.getAliveProcessName(FileApp.fContext))) {
LogEx.logDebug(TAG, "app当前进程未拉起不推送")
EventHelper.event("pushCircleOrder_isPush", "app当前进程未拉起不推送", eventParams = eventParams)
LogEx.logDebug(TAG, "================================app当前进程未拉起拦截===============================")
EventHelper.event("pushCircleOrder_isPush", "app当前进程未拉起拦截", eventParams = eventParams)
return false
}
return true
}
......@@ -106,8 +100,9 @@ object PushManager {
val pushCfg: PushCfg? = ComUtils.getPushTypeData(actionId.toString())
val pushInterval = pushCfg?.push_interval ?: 0
val lastTypePushTime = FileApp.fContext.queryDataStoreBlock(createByActionId(actionId), 0L)
return (System.currentTimeMillis() - lastTypePushTime) / 1000 > pushInterval
val actionInterval = (System.currentTimeMillis() - lastTypePushTime) / 1000
LogEx.logDebug(TAG, "actionId=$actionId actionInterval=$actionInterval pushInterval=$pushInterval")
return actionInterval > pushInterval
}
}
\ No newline at end of file
......@@ -350,7 +350,7 @@ object NotificationHelper {
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo24)
.setSmallIcon(R.mipmap.logo_small)
.setCustomContentView(remoteViews)
.setCustomBigContentView(remoteViews)
.setPriority(NotificationCompat.PRIORITY_HIGH)
......
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