| | |
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.controller.admin.PushController;
|
| | | import com.yeshi.fanli.dto.push.PushTypeEnum;
|
| | | import com.yeshi.fanli.entity.xinge.MessageInfo;
|
| | | import com.yeshi.fanli.entity.xinge.PushRecord;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | public static String allPushIOS(List<String> deviceTokenList, MessageInfo info, String url, int type)
|
| | | throws Exception {
|
| | |
|
| | | if (Constant.IS_TEST)
|
| | | return null;
|
| | | // if (Constant.IS_TEST)
|
| | | // return null;
|
| | |
|
| | | Gson gson = new Gson();
|
| | | PushLogHelper.iosInfo("IOS推送设备数为:" + deviceTokenList.size());
|
| | |
| | | // json自定义传值
|
| | |
|
| | | JSONObject json = null;
|
| | | if (type == PushController.GOODS) {
|
| | | if (type == PushTypeEnum.goodsdetail.getCode()) {
|
| | | Long auctionId = null;
|
| | | if (url.contains("id=")) {
|
| | | String[] sts = url.split("\\?")[1].split("&");
|
| | |
| | | if (auctionId == null)
|
| | | throw new Exception("淘宝商品ID提取出错");
|
| | | json = IOSPushFactory.createGoodsPush(auctionId, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.URL) {
|
| | | } else if (type == PushTypeEnum.url.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createURLPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.ZNX) {
|
| | | } else if (type == PushTypeEnum.ZNX.getCode()) {
|
| | | json = IOSPushFactory.createZNXPush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WEEX) {
|
| | | } else if (type == PushTypeEnum.weex.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createWEEXPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.BAICHUAN) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | } else if (type == PushTypeEnum.baichuan.getCode()) {
|
| | | String shortUrl = url;
|
| | | // HttpUtil.getShortLink(url);
|
| | | // if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | // throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WELFARE_CENTER) {
|
| | | } else if (type == PushTypeEnum.welfare.getCode()) {
|
| | | json = IOSPushFactory.createWelfarePush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushTypeEnum.signin.getCode()) {
|
| | | json = IOSPushFactory.createUserSignInPush(info.getTitle(), info.getContent());
|
| | | }
|
| | |
|
| | | // 分组推送 每50个设备为一组
|
| | |
|
| | | InputStream certificate = IOSPushUtil.class.getClassLoader()
|
| | |
| | |
|
| | | // json自定义传值
|
| | | JSONObject json = null;
|
| | | if (type == PushController.GOODS) {
|
| | | if (type == PushTypeEnum.goodsdetail.getCode()) {
|
| | | Long auctionId = null;
|
| | | if (url.contains("id=")) {
|
| | | String[] sts = url.split("\\?")[1].split("&");
|
| | |
| | | if (auctionId == null)
|
| | | throw new Exception("淘宝商品ID提取出错");
|
| | | json = IOSPushFactory.createGoodsPush(auctionId, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.URL) {
|
| | | } else if (type == PushTypeEnum.url.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createURLPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.ZNX) {
|
| | | } else if (type == PushTypeEnum.ZNX.getCode()) {
|
| | | json = IOSPushFactory.createZNXPush(info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.WEEX) {
|
| | | } else if (type == PushTypeEnum.weex.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | shortUrl = url;
|
| | | json = IOSPushFactory.createWEEXPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushController.BAICHUAN) {
|
| | | } else if (type == PushTypeEnum.baichuan.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | shortUrl = url;
|
| | | json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushTypeEnum.signin.getCode()) {
|
| | | json = IOSPushFactory.createUserSignInPush(info.getTitle(), info.getContent());
|
| | | }
|
| | |
|
| | | return json;
|