Commit 93e19780 authored by wanglei's avatar wanglei

...

parent 67d6402e
......@@ -2,9 +2,7 @@ package com.base.pdfviewerscannerwhite.fcm;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.base.pdfviewerscannerwhite.helper.EventUtils;
import com.base.pdfviewerscannerwhite.utils.LogEx;
import com.google.firebase.messaging.FirebaseMessagingService;
......@@ -20,6 +18,9 @@ public class MessagingService extends FirebaseMessagingService {
super.onMessageReceived(remoteMessage);
LogEx.INSTANCE.logDebug(TAG, "onMessageReceived", false);
EventUtils.INSTANCE.event("FCM_Received", null, null, false);
String action = NotificationUiUtil.INSTANCE.getNextActionId();
NotificationUiUtil.INSTANCE.sendNotification(this, action, PopupConstObject.POPUP_WHERE_FCM);
}
......
......@@ -17,15 +17,18 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_NEW_I
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_DOCUMENTS
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_READ_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_UN_VIEW_FILES
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_FCM
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_LOCK
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_TIMBER
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_count
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_end
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_fcm_interval
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_interval
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_lock_interval
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_start
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_status
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.popup_timber_interval
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import com.base.pdfviewerscannerwhite.utils.AppPreferences
......@@ -75,6 +78,7 @@ object NotificationUiUtil {
//是否开启推送
val status = AppPreferences.getInstance().getString(popup_status, "1").toInt()
if (status == 0) {
EventUtils.event("Notification_Error", "status=$status")
LogEx.logDebug("canSendNotification", "status")
return false
}
......@@ -82,6 +86,7 @@ object NotificationUiUtil {
val count = AppPreferences.getInstance().getString(popup_count, "20").toInt()
if (dayPopupCount > count) {
LogEx.logDebug("canSendNotification", "count")
EventUtils.event("Notification_Error", "dayPopupCount=$dayPopupCount count=$count")
return false
}
//判断是否在时间区域
......@@ -91,6 +96,7 @@ object NotificationUiUtil {
val currentHour = calendar.get(Calendar.HOUR_OF_DAY)
if (currentHour !in start until end) {
LogEx.logDebug("canSendNotification", "start end")
EventUtils.event("Notification_Error", "start=$start end=$end currentHour=$currentHour")
return false
}
......@@ -102,7 +108,11 @@ object NotificationUiUtil {
if (where == POPUP_WHERE_LOCK) {
interval = AppPreferences.getInstance().getString(popup_lock_interval, "1").toInt()
}
if (where == POPUP_WHERE_FCM) {
interval = AppPreferences.getInstance().getString(popup_fcm_interval, "1").toInt()
}
if (System.currentTimeMillis() - lastPopupTime < interval * 60 * 1000L) {
EventUtils.event("Notification_Error", "where=$where interval=$interval")
LogEx.logDebug("canSendNotification", "interval")
return false
}
......
......@@ -4,6 +4,7 @@ object PopupConstObject {
const val POPUP_WHERE_TIMBER = "Timber"
const val POPUP_WHERE_LOCK = "Lock"
const val POPUP_WHERE_FCM = "fcm"
//推送总开关 0 关 1开
val popup_status = "popup_status"
......@@ -16,6 +17,7 @@ object PopupConstObject {
val popup_interval = "popup_interval"
val popup_timber_interval = "popup_timber_interval"
val popup_lock_interval = "popup_lock_interval"
val popup_fcm_interval = "popup_fcm_interval"
//推送样式一配置
val popup_style1_start = "popup_style1_start"
......
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