欢迎使用CSDN-markdown编辑器

java 后台集成极光推送Demo

新接手的项目有消息推送的模块,app端的同事说要使用极光推送,需要后台这边集成极光推送,以前没有使用过极光推送,所以一开始还是有点不知道如何下手,集成的过程也是出现一些问题,一直弄了几天才弄好.

申请极光的账号和密码,下载极光的sdk这些都没什么问题,我主要说一下怎么在项目写极光推送的代码.
我使用maven构建项目,所以先引入极光的依赖,我用的是3.1.3版本的,也可以使用最新的,这都无所谓.
这里写图片描述

我理解的极光推送,主要需要3个要素,推送平台,推送方式,推送用户.(我下面说的都是在我这个项目中用到的)
1 推送平台:指推送给安卓用户还是IOS用户(它还有一个是windows手机的,但是我这个项目只有Android和IOS)

2 推送方式:有多种,我项目中只用到了通知和透传,通知会显示在手机通知栏上,透传则不会)

3 推送用户:有多种,我项目中只用到了aliase,tag ,你要推送消息,总的知道要推送给谁,某个用户或某些用户,aliase指别名,我这里使用用户id可以确定的推送给某个指定用户,tag指标签,比如你要推送给所有上海地区的用户就可以使用这个.

我项目中是先确定这三个,然后调用构建payload的方法,payload根据自己的需要设置参数进行构建,最后调用推送的方法进行推送.

我这里遇到一个问题,推送平台包括IOS的话,要实现IOS接收到消息时app的角标实现自动递增的话在构建payload的时候要加上incrBadge(1)这个参数
这里写图片描述

package com.ants.util;
import java.util.ArrayList;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import cn.jpush.api.JPushClient;
import cn.jpush.api.common.APIConnectionException;
import cn.jpush.api.common.APIRequestException;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.audience.AudienceTarget;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.IosNotification;
import cn.jpush.api.push.model.notification.Notification;

/**
 * 极光推送
 * 
 * @author stone
 *
 */
public class JiGuangUtil {
    private static Logger log = LoggerFactory.getLogger(JiGuangUtil.class);

    private static JPushClient jPushClient = new JPushClient("你申请的极光账号", "密码");

    /**
     * 调用极光推送的方法
     * 
     * @param platFormType
     *            0:推送平台为所有(android和ios) ,1:推送平台为android 2:推送平台为ios
     * @param sendMethodType
     *            0:推送方式为所有(通知和透传) ,1:推送方式为通知, 2:推送方式为透传
     * @param aliases
     * @param tags
     * @param map
     */
    public static void useJiGuang(Integer platFormType, Integer sendMethodType, ArrayList<String> aliases,
            ArrayList<String> tags, Map<String, Object> map) {
        // 判断推送的平台
        // 推送平台是android和ios
        if (platFormType == 0) {
            // 判断推送方式
            if (sendMethodType == 0) {
                // 推送方式为通知和透传
                // 调用判断推送用户类型并进行推送的方法
                judge_PlatFormTypeZero_sendMethodTypeZero(aliases, tags, map);
            }
            if (sendMethodType == 1) {
                // 推送方式是通知
                judge_PlatFormTypeZero_SendMethodTypeOne(aliases, tags, map);
            }
            if (sendMethodType == 2) {
                // 推送方式是透传
                judge_PlatFormTypeZero_SendMethodTypeTwo(aliases, tags, map);
            }
        }
        // 推送平台是android
        if (platFormType == 1) {
            // 推送平台是android
            // 判断推送方式
            if (sendMethodType == 0) {
                // 推送方式为通知和透传
                // 调用判断推送用户类型并进行推送的方法
                judge_PlatFormTypeOne_sendMethodTypeZero(aliases, tags, map);
            }
            if (sendMethodType == 1) {
                // 推送方式是通知
                judge_PlatFormTypeOne_SendMethodTypeOne(aliases, tags, map);
            }
            if (sendMethodType == 2) {
                // 推送方式是透传
                judge_PlatFormTypeOne_SendMethodTypeTwo(aliases, tags, map);
            }

        }
        // 推送平台是ios
        if (platFormType == 2) {
            // 推送平台是ios
            // 判断推送方式
            if (sendMethodType == 0) {
                // 推送方式为通知和透传
                // 调用判断推送用户类型并进行推送的方法
                judge_PlatFormTypeTwo_sendMethodTypeZero(aliases, tags, map);
            }
            if (sendMethodType == 1) {
                // 推送方式是通知
                judge_PlatFormTypeTwo_SendMethodTypeOne(aliases, tags, map);
            }
            if (sendMethodType == 2) {
                // 推送方式是透传
                judge_PlatFormTypeTwo_SendMethodTypeTwo(aliases, tags, map);
            }
        }
    }

    // 判断推送用户类型的方法,::推送平台为所有,推送方式为所有,
    public static void judge_PlatFormTypeZero_sendMethodTypeZero(ArrayList<String> aliases, ArrayList<String> tags,
            Map<String, Object> map) {
        if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
            // 推送给所有的用户
            // 推送平台为所有,所有方式为所有,推送用户为所有
//          sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceZero(map);
        }
        if (aliases.size() > 0 && tags.size() > 0) {
            // 推送平台为所有,所有方式为所有,推送用户为 tags和aliases
            sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceOne(aliases, tags, map);
        }
        if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
            // 推送平台为所有,所有方式为所有,推送用户为 aliases
            sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceTwo(aliases, map);
        }
        if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
            // 推送平台为所有,所有方式为所有,推送用户为 tags
            sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceThree(tags, map);
        }
    }

    /*  // 推送平台为所有,所有方式为通知和透传,推送用户为所有
    public static void sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceZero(Map<String, Object> map) {
        String content = (String) map.get("content");
        Integer type = (Integer) map.get("type");
        Object data = map.get("data");
        Object title = map.get("title");
        String typeJson = JSON.toJSONString(type);
        String dataJson = JSON.toJSONString(data);
        String titleJson = JSON.toJSONString(title);
        PushPayload payload = PushPayload.newBuilder().setPlatform(Platform.all()).setAudience(Audience.all())
                .setNotification(Notification.newBuilder().setAlert(content)
                        .addPlatformNotification(AndroidNotification.newBuilder().setTitle(titleJson)
                                .addExtra("type", typeJson).addExtra("data", dataJson).build())
                        .addPlatformNotification(
                                IosNotification.newBuilder().addExtra("type", typeJson).addExtra("data", dataJson)
                                        .addExtra("title", titleJson).setContentAvailable(true).build())
                        .build())
                .setMessage(Message.newBuilder().setMsgContent(content).addExtra("type", typeJson)
                        .addExtra("data", dataJson).addExtra("title", titleJson).build())
                .build();

        // 调用推送的方法
        sendPush(payload);
    }*/

    // 推送平台为所有,推送方式为所有,推送用户为 tags和aliases
    public static PushPayload sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceOne(ArrayList<String> aliases,
            ArrayList<String> tags, Map<String, Object> map) {
        String content = (String) map.get("content");
        Integer type = (Integer) map.get("type");
        Object data = map.get("data");
        Object title = map.get("title");
        String typeJson = JSON.toJSONString(type);
        String dataJson = JSON.toJSONString(data);
        String titleJson = JSON.toJSONString(title);

        PushPayload payload = PushPayload.newBuilder().setPlatform(Platform.all())
                .setAudience(Audience.newBuilder()//此时的用户关系是   tags且aliases
                        .addAudienceTarget(AudienceTarget.tag(tags))
                        .addAudienceTarget(AudienceTarget.alias(aliases))
                        .build())
                .setNotification(Notification.newBuilder().setAlert(content)
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                .setTitle(titleJson)
                                .addExtra("type", typeJson)
                                .addExtra("data", dataJson)
                                .build())
                        .addPlatformNotification(
                                IosNotification.newBuilder()
                                        .addExtra("type", typeJson)
                                        .addExtra("data", dataJson)
                                        .addExtra("title", titleJson)
                                        .setContentAvailable(false)
                                        .incrBadge(1)
                                        .build())
                        .build())
                .setMessage(Message.newBuilder().setMsgContent(content).addExtra("type", typeJson)
                        .addExtra("data", dataJson).addExtra("title", titleJson).build())
                .build();

        // 调用推送的方法
        sendPush(payload);
        return payload;
    }

    // 推送平台为所有,推送方式为所有,推送用户为 aliases
    public static void sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceTwo(ArrayList<String> aliases,
            Map<String, Object> map) {
        String content = (String) map.get("content");
        Integer type = (Integer) map.get("type");
        Object data = map.get("data");
        Object title = map.get("title");
        String typeJson = JSON.toJSONString(type);
        String dataJson = JSON.toJSONString(data);
        System.out.println("dataJson: "+ dataJson);
        String titleJson = JSON.toJSONString(title);

        PushPayload payload = PushPayload.newBuilder()
                .setPlatform(Platform.all())
                .setAudience(Audience.alias(aliases))
                .setNotification(Notification.newBuilder().setAlert(content)
                        .addPlatformNotification(AndroidNotification.newBuilder()
                                .setTitle(titleJson)
                                .addExtra("type", type)
                                .addExtra("data", dataJson)
                                .build())
                        .addPlatformNotification(
                                IosNotification.newBuilder()
                                .addExtra("type", typeJson)
                                .addExtra("data", dataJson)
                                .addExtra("title", titleJson)
                                .incrBadge(1)
                                .setContentAvailable(false).build())
                        .build())
                .setMessage(Message.newBuilder().setMsgContent(content)
                        .addExtra("type", typeJson)
                        .addExtra("data", dataJson)
                        .addExtra("title", titleJson)
                        .build())
                .build();

        // 调用推送的方法
        sendPush(payload);
    }

    // 推送平台为所有,推送方式为所有,推送用户为tags
        public static void sendMessage_PlatFormTypeZero_SendMethodTypeZero_AudienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            System.out.println("dataJson: "+dataJson);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", type)
                                    .addExtra("data", dataJson)
                                    .build())
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .incrBadge(1)
                                    .setContentAvailable(false).build())
                            .build())
                    .setMessage(Message.newBuilder().setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为所有,推送方式为所有,推送用户为tags(专门为下线推送的使用 )
        public static void sendLogOff(String tag1 ,String tag2,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            System.out.println("dataJson: "+dataJson);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.tag_and(tag1,tag2))   
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", type)
                                    .addExtra("data", dataJson)
                                    .build())
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .incrBadge(1)
                                    .setContentAvailable(false).build())
                            .build())
                    .setMessage(Message.newBuilder().setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }


        // 判断推送用户类型的方法,::推送平台为所有,推送方式为通知,
        public static void judge_PlatFormTypeZero_SendMethodTypeOne(ArrayList<String> aliases, ArrayList<String> tags,
                Map<String, Object> map) {
            if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
                // 推送平台为所有,推送方式为通知,,推送用户为所有
                sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceZero(map);
            }
            if (aliases.size() > 0 && tags.size() > 0) {
                // 推送平台为所有,推送方式为通知,,推送用户为aliases和tags
                sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceOne(aliases, tags, map);
            }
            if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
                // 推送平台为所有,推送方式为通知,,推送用户为aliases
                sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceTwo(aliases, map);
            }
            if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
                // 推送平台为所有,推送方式为通知,,推送用户为tags
                sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceThree(tags, map);
            }

        }

        // 推送平台为所有,推送方式为通知,,推送用户为所有
        private static void sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceZero(Map<String, Object> map) {
            // TODO Auto-generated method stub
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.all())
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", type)
                                    .addExtra("data", dataJson)
                                    .build())
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .incrBadge(1)
                                    .setContentAvailable(false).build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为所有,推送方式为通知,,推送用户为aliases和tags
        private static void sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceOne(ArrayList<String> aliases,
                ArrayList<String> tags, Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.alias(aliases))
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", type)
                                    .addExtra("data", dataJson)
                                    .build())
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .incrBadge(1)
                                    .setContentAvailable(false).build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }

        // 推送平台为所有,推送方式为通知,,推送用户为aliases
        public static void sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceTwo(ArrayList<String> aliases,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            log.info("content: "+content);
            log.info("type: "+type);
            log.info("data: "+data);
            log.info("typeJson: "+typeJson);
            log.info("dataJson: "+dataJson);
            log.info("titleJson: "+titleJson);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.alias(aliases))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .incrBadge(1)
                                    .setContentAvailable(true).build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为所有,所有方式为通知,推送用户为 tags
        private static void sendMessage_PlatFormTypeZero_SendMethodTypeOne_AudienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.alias(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", type)
                                    .addExtra("data", dataJson)
                                    .build())
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .incrBadge(1)
                                    .setContentAvailable(false).build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }   
        // 判断推送用户类型的方法,::推送平台为所有,推送方式为透传,
        public static void judge_PlatFormTypeZero_SendMethodTypeTwo(ArrayList<String> aliases, ArrayList<String> tags,
                Map<String, Object> map) {
            if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
                // 推送平台为所有,推送方式为透传,,推送用户为所有
                sendMessage_PlatFormTypeZero_SendMethodTypeTwo_AudienceZero(map);
            }
            if (aliases.size() > 0 && tags.size() > 0) {
                // 推送平台为所有,推送方式为透传,,推送用户为aliases和tags
                sendMessage_PlatFormTypeZero_SendMethodTypeTwo_AudienceOne(aliases, tags, map);
            }
            if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
                // 推送平台为所有,推送方式为透传,,推送用户为aliases
                sendMessage_PlatFormTypeZero_SendMethodTypeTwo_AudienceTwo(aliases, map);
            }
            if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
                // 推送平台为所有,推送方式为透传,,推送用户为tags
                sendMessage_PlatFormTypeZero_SendMethodTypeTwo_audienceThree(tags, map);
            }
        }   

        // 推送平台为所有,推送方式为透传,,推送用户为所有
        private static void sendMessage_PlatFormTypeZero_SendMethodTypeTwo_AudienceZero(Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.all())
                    .setMessage(Message.newBuilder().setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }


        // 推送平台为所有,推送方式为透传,,推送用户为aliases和tags
        private static void sendMessage_PlatFormTypeZero_SendMethodTypeTwo_AudienceOne(ArrayList<String> aliases,
                ArrayList<String> tags, Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.alias(aliases))
                    .setAudience(Audience.tag(tags))
                    .setMessage(Message.newBuilder().setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }


        // 推送平台为所有,推送方式为透传,,推送用户为aliases
        private static void sendMessage_PlatFormTypeZero_SendMethodTypeTwo_AudienceTwo(ArrayList<String> aliases,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.alias(aliases))
                    .setMessage(Message.newBuilder().setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }   
        // 推送平台为所有,推送方式为透传,,推送用户为tags
        public static void sendMessage_PlatFormTypeZero_SendMethodTypeTwo_audienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);

            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.tag(tags))
                    .setMessage(Message.newBuilder().setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }

        // 判断推送用户类型的方法,::推送平台为android,推送方式为所有,
        public static void judge_PlatFormTypeOne_sendMethodTypeZero(ArrayList<String> aliases, ArrayList<String> tags,
                Map<String, Object> map) {
            if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
                // 推送给所有的用户
                // 推送平台为android,所有方式为所有,推送用户为所有
                sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceZero(map);
            }
            if (aliases.size() > 0 && tags.size() > 0) {
                // 推送平台为android,推送方式为所有,推送用户为 tags和aliases
                sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceOne(aliases, tags, map);
            }
            if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
                // 推送平台为android,推送方式为所有,推送用户为 aliases
                sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceTwo(aliases, map);
            }
            if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
                // 推送平台为android,推送方式为所有,推送用户为 tags
                sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceThree(tags, map);
            }

        }   

        // 推送平台为android,推送方式为所有,推送用户为所有
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceZero(Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.all())
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为android,推送方式为所有,推送用户为 tags和aliases
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceOne(ArrayList<String> aliases,
                ArrayList<String> tags, Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.alias(aliases))
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);

        }
        // 推送平台为android,推送方式为所有,推送用户为 aliases
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceTwo(ArrayList<String> aliases,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.alias(aliases))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);

        }
        // 推送平台为android,推送方式为所有,推送用户为 tags
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeZero_AudienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);

        }

        // 判断推送用户类型的方法,::推送平台为android,推送方式为通知,
        public static void judge_PlatFormTypeOne_SendMethodTypeOne(ArrayList<String> aliases, ArrayList<String> tags,
                Map<String, Object> map) {
            if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
                // 推送给所有的用户
                // 推送平台为android,所有方式为通知,推送用户为所有
                sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceZero(map);
            }
            if (aliases.size() > 0 && tags.size() > 0) {
                // 推送平台为android,推送方式为通知,推送用户为 tags和aliases
                sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceOne(aliases, tags, map);
            }
            if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
                // 推送平台为android,推送方式为通知,推送用户为 aliases
                sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceTwo(aliases, map);
            }
            if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
                // 推送平台为android,推送方式为通知,推送用户为 tags
                sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceThree(tags, map);
            }

        }

        // 推送平台为android,推送方式为通知,推送用户为所有
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceZero(Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.all())
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为android,推送方式为通知,推送用户为 tags和aliases
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceOne(ArrayList<String> aliases,
                ArrayList<String> tags, Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.alias(aliases))
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为android,推送方式为通知,推送用户为 aliases
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceTwo(ArrayList<String> aliases,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.alias(aliases))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }

        // 推送平台为android,推送方式为通知,推送用户为 tags
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeOne_AudienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(AndroidNotification.newBuilder()
                                    .setTitle(titleJson)
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }

        // 判断推送用户类型的方法,::推送平台为android,推送方式为透传,
        public static void judge_PlatFormTypeOne_SendMethodTypeTwo(ArrayList<String> aliases, ArrayList<String> tags,
                Map<String, Object> map) {
            if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
                // 推送给所有的用户
                // 推送平台为android,推送方式为透传,推送用户为所有
                sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceZero(map);
            }
            if (aliases.size() > 0 && tags.size() > 0) {
                // 推送平台为android,推送方式为透传,推送用户为 tags和aliases
                sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceOne(aliases, tags, map);
            }
            if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
                // 推送平台为android,推送方式为透传,推送用户为 aliases
                sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceTwo(aliases, map);
            }
            if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
                // 推送平台为android,推送方式为透传,推送用户为 tags
                sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceThree(tags, map);
            }

        }

        // 推送平台为android,推送方式为透传,推送用户为所有
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceZero(Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.all())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为android,推送方式为透传,推送用户为 tags和aliases
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceOne(ArrayList<String> aliases,
                ArrayList<String> tags, Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.alias(aliases))
                    .setAudience(Audience.tag(tags))
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为android,推送方式为透传,推送用户为 aliases
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceTwo(ArrayList<String> aliases,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.alias(aliases))
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }

        // 推送平台为android,推送方式为透传,推送用户为 tags
        private static void sendMessage_PlatFormTypeOne_SendMethodTypeTwo_AudienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.android())
                    .setAudience(Audience.tag(tags))
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }

        // 判断推送用户类型的方法,::推送平台为ios,推送方式为所有,
        public static void judge_PlatFormTypeTwo_sendMethodTypeZero(ArrayList<String> aliases, ArrayList<String> tags,
                Map<String, Object> map) {
            if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
                // 推送给所有的用户
                // 推送平台为ios,推送方式为所有,推送用户为所有
                sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceZero(map);
            }
            if (aliases.size() > 0 && tags.size() > 0) {
                // 推送平台为ios,推送方式为所有,推送用户为 tags和aliases
                sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceOne(aliases, tags, map);
            }
            if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
                // 推送平台为ios,推送方式为所有,推送用户为 aliases
                sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceTwo(aliases, map);
            }
            if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
                // 推送平台为ios,推送方式为所有,推送用户为 tags
                sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceThree(tags, map);
            }
        }


        // 推送平台为ios,推送方式为所有,推送用户为所有
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceZero(Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.all())
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();
            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为ios,推送方式为所有,推送用户为 tags和aliases
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceOne(ArrayList<String> aliases,
                ArrayList<String> tags, Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.alias(aliases))
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();
            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为ios,推送方式为所有,推送用户为 aliases
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceTwo(ArrayList<String> aliases,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.alias(aliases))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();
            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为ios,推送方式为所有,推送用户为 tags
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeZero_AudienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .setMessage(Message.newBuilder()
                            .setMsgContent(content)
                            .addExtra("type", typeJson)
                            .addExtra("data", dataJson)
                            .addExtra("title", titleJson)
                            .build())
                    .build();
            // 调用推送的方法
            sendPush(payload);
        }
        // 判断推送用户类型的方法,::推送平台为ios,推送方式为通知,
        public static void judge_PlatFormTypeTwo_SendMethodTypeOne(ArrayList<String> aliases, ArrayList<String> tags,
                Map<String, Object> map) {
            if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
                // 推送给所有的用户
                // 推送平台为ios,推送方式为通知,推送用户为所有
                sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceZero(map);
            }
            if (aliases.size() > 0 && tags.size() > 0) {
                // 推送平台为ios,推送方式为通知,推送用户为 tags和aliases
                sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceOne(aliases, tags, map);
            }
            if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
                // 推送平台为ios,推送方式为通知,推送用户为 aliases
                sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceTwo(aliases, map);
            }
            if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
                // 推送平台为ios,推送方式为通知,推送用户为 tags
                sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceThree(tags, map);
            }
        }
        // 推送平台为ios,推送方式为通知,推送用户为所有
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceZero(Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.all())
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为ios,推送方式为通知,推送用户为 tags和aliases
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceOne(ArrayList<String> aliases,
                ArrayList<String> tags, Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.alias(aliases))
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为ios,推送方式为通知,推送用户为 aliases
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceTwo(ArrayList<String> aliases,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.alias(aliases))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }
        // 推送平台为ios,推送方式为通知,推送用户为 tags
        private static void sendMessage_PlatFormTypeTwo_SendMethodTypeOne_AudienceThree(ArrayList<String> tags,
                Map<String, Object> map) {
            String content = (String) map.get("content");
            Integer type = (Integer) map.get("type");
            Object data = map.get("data");
            Object title = map.get("title");
            String typeJson = JSON.toJSONString(type);
            String dataJson = JSON.toJSONString(data);
            String titleJson = JSON.toJSONString(title);
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.ios())
                    .setAudience(Audience.tag(tags))
                    .setNotification(Notification.newBuilder().setAlert(content)
                            .addPlatformNotification(
                                    IosNotification.newBuilder()
                                    .addExtra("type", typeJson)
                                    .addExtra("data", dataJson)
                                    .addExtra("title", titleJson)
                                    .setContentAvailable(false)
                                    .incrBadge(1)
                                    .build())
                            .build())
                    .build();

            // 调用推送的方法
            sendPush(payload);
        }

    // 判断推送用户类型的方法,::推送平台为ios,推送方式为透传,
    public static void judge_PlatFormTypeTwo_SendMethodTypeTwo(ArrayList<String> aliases, ArrayList<String> tags,
            Map<String, Object> map) {
        if ((aliases.size() == 0 || aliases == null) && (tags.size() == 0 || tags == null)) {
            // 推送给所有的用户
            // 推送平台为ios,推送方式为透传,推送用户为所有
            sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceZero(map);
        }
        if (aliases.size() > 0 && tags.size() > 0) {
            // 推送平台为ios,推送方式为透传,推送用户为 tags和aliases
            sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceOne(aliases, tags, map);
        }
        if (aliases.size() > 0 && (tags.size() == 0 || tags == null)) {
            // 推送平台为ios,推送方式为透传,推送用户为 aliases
            sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceTwo(aliases, map);
        }
        if ((aliases.size() == 0 || aliases == null) && tags.size() > 0) {
            // 推送平台为ios,推送方式为透传,推送用户为 tags
            sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceThree(tags, map);
        }
    }
    // 推送平台为ios,推送方式为透传,推送用户为所有
    private static void sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceZero(Map<String, Object> map) {
        String content = (String) map.get("content");
        Integer type = (Integer) map.get("type");
        Object data = map.get("data");
        Object title = map.get("title");
        String typeJson = JSON.toJSONString(type);
        String dataJson = JSON.toJSONString(data);
        String titleJson = JSON.toJSONString(title);
        PushPayload payload = PushPayload.newBuilder()
                .setPlatform(Platform.ios())
                .setAudience(Audience.all())
                .setMessage(Message.newBuilder()
                        .setMsgContent(content)
                        .addExtra("type", typeJson)
                        .addExtra("data", dataJson)
                        .addExtra("title", titleJson)
                        .build())
                .build();

        // 调用推送的方法
        sendPush(payload);
    }
    // 推送平台为ios,推送方式为透传,推送用户为 tags和aliases
    private static void sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceOne(ArrayList<String> aliases,
            ArrayList<String> tags, Map<String, Object> map) {
        String content = (String) map.get("content");
        Integer type = (Integer) map.get("type");
        Object data = map.get("data");
        Object title = map.get("title");
        String typeJson = JSON.toJSONString(type);
        String dataJson = JSON.toJSONString(data);
        String titleJson = JSON.toJSONString(title);
        PushPayload payload = PushPayload.newBuilder()
                .setPlatform(Platform.ios())
                .setAudience(Audience.alias(aliases))
                .setAudience(Audience.tag(tags))
                .setMessage(Message.newBuilder()
                        .setMsgContent(content)
                        .addExtra("type", typeJson)
                        .addExtra("data", dataJson)
                        .addExtra("title", titleJson)
                        .build())
                .build();

        // 调用推送的方法
        sendPush(payload);
    }

    // 推送平台为ios,推送方式为透传,推送用户为 aliases
    private static void sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceTwo(ArrayList<String> aliases,
            Map<String, Object> map) {
        String content = (String) map.get("content");
        Integer type = (Integer) map.get("type");
        Object data = map.get("data");
        Object title = map.get("title");
        String typeJson = JSON.toJSONString(type);
        String dataJson = JSON.toJSONString(data);
        String titleJson = JSON.toJSONString(title);
        PushPayload payload = PushPayload.newBuilder()
                .setPlatform(Platform.ios())
                .setAudience(Audience.alias(aliases))
                .setMessage(Message.newBuilder()
                        .setMsgContent(content)
                        .addExtra("type", typeJson)
                        .addExtra("data", dataJson)
                        .addExtra("title", titleJson)
                        .build())
                .build();

        // 调用推送的方法
        sendPush(payload);
    }

    // 推送平台为ios,推送方式为透传,推送用户为 tags
    private static void sendMessage_PlatFormTypeTwo_SendMethodTypeTwo_AudienceThree(ArrayList<String> tags,
            Map<String, Object> map) {
        String content = (String) map.get("content");
        Integer type = (Integer) map.get("type");
        Object data = map.get("data");
        Object title = map.get("title");
        String typeJson = JSON.toJSONString(type);
        String dataJson = JSON.toJSONString(data);
        String titleJson = JSON.toJSONString(title);
        PushPayload payload = PushPayload.newBuilder()
                .setPlatform(Platform.ios())
                .setAudience(Audience.alias(tags))
                .setMessage(Message.newBuilder()
                        .setMsgContent(content)
                        .addExtra("type", typeJson)
                        .addExtra("data", dataJson)
                        .addExtra("title", titleJson)
                        .build())
                .build();

        // 调用推送的方法
        sendPush(payload);
    }
    // 进行推送的方法
    private static void sendPush(PushPayload payload) {
        try {
            @SuppressWarnings("unused")
            PushResult result = jPushClient.sendPush(payload);
            log.info("JPushClient sendPush Success ! !");

        } catch (APIConnectionException ex) {
            log.info(String.format("====APIConnectionException - %s", ex.getMessage()));

            ex.printStackTrace();
        } catch (APIRequestException ex) {
            log.info(String.format("====APIRequestException - %s", ex.getMessage()));
            ex.printStackTrace();
        }

    }

}


欢迎使用Markdown编辑器写博客

本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:

  • Markdown和扩展Markdown简洁的语法
  • 代码块高亮
  • 图片链接和图片上传
  • LaTex数学公式
  • UML序列图和流程图
  • 离线写博客
  • 导入导出Markdown文件
  • 丰富的快捷键

快捷键

  • 加粗 Ctrl + B
  • 斜体 Ctrl + I
  • 引用 Ctrl + Q
  • 插入链接 Ctrl + L
  • 插入代码 Ctrl + K
  • 插入图片 Ctrl + G
  • 提升标题 Ctrl + H
  • 有序列表 Ctrl + O
  • 无序列表 Ctrl + U
  • 横线 Ctrl + R
  • 撤销 Ctrl + Z
  • 重做 Ctrl + Y

Markdown及扩展

Markdown 是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档,然后转换成格式丰富的HTML页面。 —— [ 维基百科 ]

使用简单的符号标识不同的标题,将某些文字标记为粗体或者斜体,创建一个链接等,详细语法参考帮助?。

本编辑器支持 Markdown Extra ,  扩展了很多好用的功能。具体请参考Github.

表格

Markdown Extra 表格语法:

项目价格
Computer$1600
Phone$12
Pipe$1

可以使用冒号来定义对齐方式:

项目价格数量
Computer1600 元5
Phone12 元12
Pipe1 元234

定义列表

Markdown Extra 定义列表语法: 项目1 项目2
定义 A
定义 B
项目3
定义 C

定义 D

定义D内容

代码块

代码块语法遵循标准markdown代码,例如:

@requires_authorization
def somefunc(param1='', param2=0):
    '''A docstring'''
    if param1 > param2: # interesting
        print 'Greater'
    return (param2 - param1 + 1) or None
class SomeClass:
    pass
>>> message = '''interpreter
... prompt'''

脚注

生成一个脚注1.

目录

[TOC]来生成目录:

数学公式

使用MathJax渲染LaTex 数学公式,详见math.stackexchange.com.

  • 行内公式,数学公式为: Γ(n)=(n1)!nN
  • 块级公式:

x=b±b24ac2a

更多LaTex语法请参考 这儿.

UML 图:

可以渲染序列图:

Created with Raphaël 2.1.0 张三 张三 李四 李四 嘿,小四儿, 写博客了没? 李四愣了一下,说: 忙得吐血,哪有时间写。

或者流程图:

Created with Raphaël 2.1.0 开始 我的操作 确认? 结束 yes no
  • 关于 序列图 语法,参考 这儿,
  • 关于 流程图 语法,参考 这儿.

离线写博客

即使用户在没有网络的情况下,也可以通过本编辑器离线写博客(直接在曾经使用过的浏览器中输入write.blog.csdn.net/mdeditor即可。Markdown编辑器使用浏览器离线存储将内容保存在本地。

用户写博客的过程中,内容实时保存在浏览器缓存中,在用户关闭浏览器或者其它异常情况下,内容不会丢失。用户再次打开浏览器时,会显示上次用户正在编辑的没有发表的内容。

博客发表后,本地缓存将被删除。 

用户可以选择 把正在写的博客保存到服务器草稿箱,即使换浏览器或者清除缓存,内容也不会丢失。

注意:虽然浏览器存储大部分时候都比较可靠,但为了您的数据安全,在联网后,请务必及时发表或者保存到服务器草稿箱

浏览器兼容

  1. 目前,本编辑器对Chrome浏览器支持最为完整。建议大家使用较新版本的Chrome。
  2. IE9以下不支持
  3. IE9,10,11存在以下问题
    1. 不支持离线功能
    2. IE9不支持文件导入导出
    3. IE10不支持拖拽文件导入


  1. 这里是 脚注内容.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值