admin
2022-01-12 4a7367a869ef12375ea6678ca44e102b8919c624
service-push/src/main/java/com/ks/push/utils/PushUtil.java
@@ -1,9 +1,10 @@
package com.ks.push.utils;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.huawei.push.util.push.*;
import com.ks.push.pojo.DO.BPushMessage;
import com.ks.push.pojo.DO.PushPlatform;
import com.ks.push.utils.push.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yeshi.utils.StringUtil;
@@ -70,6 +71,8 @@
            pushVIVO(appInfo, message, tokenList);
        } else if (platform == PushPlatform.mz) {
            pushMZ(appInfo, message, tokenList);
        } else if (platform == PushPlatform.jpush) {
            pushJPush(appInfo, message, tokenList,!pushMessage.isMessage());
        }
    }
@@ -135,4 +138,28 @@
    }
    /**
     * 极光推送
     *
     * @param appInfo
     * @param message
     * @param tokenList
     * @throws Exception
     */
    private static void pushJPush(PushAppInfo appInfo, PushMessage message, List<String> tokenList, boolean alert) throws Exception {
        if (alert) {
            JpushUtil.pushNotification(appInfo, message, tokenList, null);
        } else {
            JSONObject data = new JSONObject();
            if (message.getActivityParams() != null) {
                for (Iterator<String> its = message.getActivityParams().keySet().iterator(); its.hasNext(); ) {
                    String key = its.next();
                    data.put(key, message.getActivityParams().get(key));
                }
            }
            JpushUtil.pushMessage(appInfo, data, tokenList, null);
        }
    }
}