package com.ssj.service.sys.push.service.task;

import com.ssj.conch.push.util.PushConstants;
import com.ssj.push.util.jiguang.MessagePushUtils;
import com.ssj.taskthread.Task;

/**
 * @author yangcan
 * 类描述:腾讯推送所有设备异步线程
 * 创建时间:2018年8月23日 下午2:59:35

 */
public class XingePushAllThreadTask extends Task{
	
	private String title; //极光id
	private String content; //推送内容
	private String platform;//推送平台(ANDROID,IOS,ALL)
	private int platformType;//1:贝壳端 2:家长端 3:学生端 4:老师端 5:校长端
	private int iosEnv = 2;//ios生产环境IOSENV_PROD = 1,ios开发环境 IOSENV_DEV = 2
	
	public XingePushAllThreadTask(String title, String content, String platform, int platformType,int iosEnv) {
		super();
		this.title = title;
		this.content = content;
		this.platform = platform;
		this.platformType = platformType;
		this.iosEnv = iosEnv;
	}

	public void run() {
		logger.error("信鸽异步开始推送---------------");
		try {
			if(PushConstants.PUSH_ANDROID.equals(platform)) {
				MessagePushUtils.pushAllByAndroid(title, content, platformType,"message");
			}else if(PushConstants.PUSH_IOS.equals(platform)) {
				MessagePushUtils.pushAllByIosAPNS(content, platformType, null, null, iosEnv);
			}else if(PushConstants.PUSH_ALL.equals(platform)) {
				MessagePushUtils.pushAllByAndroid(title, content, platformType,"message");
				MessagePushUtils.pushAllByIosAPNS(content, platformType, null, null, iosEnv);
			}
		}catch (Exception e) {
			logger.error("腾讯信鸽推送异常...");
		}
		logger.error(Thread.currentThread().getName()+"信鸽异步结束推送---------------");
	}
}
