增加小米推送注册regId服务,暂时取消推送时的消息免打扰过滤
| | |
| | | import com.yeshi.fanli.entity.push.DeviceActive;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenOPPO;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenVIVO;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenXM;
|
| | | import com.yeshi.fanli.entity.push.PushGoods;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsGroup;
|
| | | import com.yeshi.fanli.entity.push.PushGoodsRecord;
|
| | |
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenVIVOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenXMService;
|
| | | import com.yeshi.fanli.service.inter.push.IOSPushService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.push.PushGoodsRecordService;
|
| | |
| | |
|
| | | @Resource
|
| | | private DeviceTokenVIVOService deviceTokenVIVOService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenXMService deviceTokenXMService;
|
| | |
|
| | | @RequestMapping(value = "callback", method = RequestMethod.POST)
|
| | | public void callback(AcceptData acceptData, String pushId, PrintWriter out) {
|
| | |
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | @RequestMapping("registerXM")
|
| | | public void registerXM(AcceptData acceptData, String regId, Long uid, PrintWriter out) {
|
| | | DeviceActive deviceActive = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
|
| | | if (deviceActive != null) {
|
| | | DeviceTokenXM xm = new DeviceTokenXM();
|
| | | xm.setDeviceActiveId(deviceActive.getId());
|
| | | xm.setRegisterId(regId);
|
| | | xm.setUid(uid);
|
| | | deviceTokenXMService.addDeviceToken(xm);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenVIVOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenXMService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | | import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
|
| | |
| | |
|
| | | @Resource
|
| | | private DeviceTokenOPPOService deviceTokenOPPOService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private DeviceTokenXMService deviceTokenXMService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenVIVOService deviceTokenVIVOService;
|
| | |
|
| | |
| | | if (active != null) {
|
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenXMService.bindUid(active.getId(), uuser.getId());
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | |
| | | deviceTokenOPPOService.unBindUid(uid, deviceActive.getId());
|
| | | // 解绑VIVO推送的用户绑定
|
| | | deviceTokenVIVOService.unBindUid(uid, deviceActive.getId());
|
| | | // 解绑XM推送的用户绑定
|
| | | deviceTokenXMService.unBindUid(deviceActive.getId());
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | |
| | | if (active != null) {
|
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenXMService.bindUid(active.getId(), uuser.getId());
|
| | | }
|
| | | }
|
| | | });
|
| | |
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenVIVOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenXMService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | |
| | | private DeviceTokenOPPOService deviceTokenOPPOService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenXMService deviceTokenXMService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenVIVOService deviceTokenVIVOService;
|
| | |
|
| | | @Resource
|
| | |
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | |
|
| | | |
| | | /**
|
| | | * 新版登录 V1.5.3
|
| | | *
|
| | |
| | | if (active != null) {
|
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenXMService.bindUid(active.getId(), uuser.getId());
|
| | | }
|
| | | }
|
| | | });
|
| | |
| | | vo.setHelpLink(userVipConfigService.getValueByKey("help_link_vip_h5"));
|
| | | vo.setCsdLink(configService.get("customer_service_link"));
|
| | |
|
| | | |
| | | Date now = new Date();
|
| | | Date start = new Date(0);
|
| | | |
| | |
|
| | | // 返利订单、奖励券提成
|
| | | List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.fanli);
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
|
| | | BigDecimal finishMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now).abs();
|
| | | |
| | | BigDecimal finishMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now)
|
| | | .abs();
|
| | |
|
| | | // 邀请订单、分享订单、补贴
|
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
|
| | | typeList.add(UserMoneyDetailTypeEnum.share);
|
| | |
| | | }
|
| | | });
|
| | | Gson gson = gsonBuilder.create();
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(vo))));
|
| | | } else {
|
New file |
| | |
| | | package com.yeshi.fanli.dao.push;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.data.domain.Sort;
|
| | | import org.springframework.data.domain.Sort.Direction;
|
| | | import org.springframework.data.domain.Sort.Order;
|
| | | import org.springframework.data.mongodb.core.MongoTemplate;
|
| | | import org.springframework.data.mongodb.core.query.BasicQuery;
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.stereotype.Repository;
|
| | |
|
| | | import com.mongodb.BasicDBObject;
|
| | | import com.mongodb.DBObject;
|
| | | import com.yeshi.fanli.dao.MongodbBaseDao;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenXM;
|
| | |
|
| | | @Repository
|
| | | public class DeviceTokenXMDao extends MongodbBaseDao<DeviceTokenXM> {
|
| | | @Resource
|
| | | private MongoTemplate mongoTemplate;
|
| | |
|
| | | public List<DeviceTokenXM> listByUid(Long uid) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("uid").is(uid));
|
| | | return mongoTemplate.find(query, DeviceTokenXM.class);
|
| | | }
|
| | |
|
| | | public DeviceTokenXM selectByDeviceActiveId(Long deviceActiveId) {
|
| | | return mongoTemplate.findById(deviceActiveId, DeviceTokenXM.class);
|
| | | }
|
| | |
|
| | | public List<String> listRegId(int start, int count) {
|
| | | DBObject fieldsObject = new BasicDBObject();
|
| | | fieldsObject.put("registerId", true);
|
| | | BasicDBObject dbObject = new BasicDBObject();
|
| | | Query query = new BasicQuery(dbObject, fieldsObject);
|
| | | query.limit(count);
|
| | | query.skip(start);
|
| | | List<Order> orders = new ArrayList<>();
|
| | | orders.add(new Order(Direction.DESC, "updateTime"));
|
| | | query.with(new Sort(orders));
|
| | | List<DeviceTokenXM> resultList = mongoTemplate.find(query, DeviceTokenXM.class);
|
| | | List<String> regList = new ArrayList<>();
|
| | | if (resultList != null) {
|
| | | for (DeviceTokenXM xm : resultList)
|
| | | regList.add(xm.getRegisterId());
|
| | | }
|
| | | return regList;
|
| | | }
|
| | |
|
| | | public long countRegId() {
|
| | | return mongoTemplate.count(new Query(), DeviceTokenXM.class);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.push;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.springframework.data.annotation.Id;
|
| | | import org.springframework.data.mongodb.core.index.Indexed;
|
| | | import org.springframework.data.mongodb.core.mapping.Document;
|
| | | import org.springframework.data.mongodb.core.mapping.Field;
|
| | |
|
| | | /**
|
| | | * XM推送
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Document(collection = "deviceTokenXM")
|
| | | public class DeviceTokenXM {
|
| | | @Id
|
| | | private Long deviceActiveId;// 设备活跃ID
|
| | | @Field
|
| | | private String registerId;
|
| | | @Indexed
|
| | | @Field
|
| | | private Long uid;
|
| | | @Field
|
| | | private Date createTime;
|
| | | @Field
|
| | | private Date updateTime;
|
| | |
|
| | | public String getRegisterId() {
|
| | | return registerId;
|
| | | }
|
| | |
|
| | | public void setRegisterId(String registerId) {
|
| | | this.registerId = registerId;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public Long getDeviceActiveId() {
|
| | | return deviceActiveId;
|
| | | }
|
| | |
|
| | | public void setDeviceActiveId(Long deviceActiveId) {
|
| | | this.deviceActiveId = deviceActiveId;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.push.DeviceTokenXMDao;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenXM;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenXMService;
|
| | |
|
| | | @Service
|
| | | public class DeviceTokenXMServiceImpl implements DeviceTokenXMService {
|
| | | @Resource
|
| | | private DeviceTokenXMDao deviceTokenXMDao;
|
| | |
|
| | | @Override
|
| | | public void addDeviceToken(DeviceTokenXM deviceToken) {
|
| | | if (deviceToken.getDeviceActiveId() == null)
|
| | | return;
|
| | | DeviceTokenXM xm = selectByDeviceActiveId(deviceToken.getDeviceActiveId());
|
| | | if (xm != null) {
|
| | | deviceToken.setCreateTime(xm.getCreateTime());
|
| | | }
|
| | |
|
| | | if (deviceToken.getUpdateTime() == null)
|
| | | deviceToken.setUpdateTime(new Date());
|
| | | deviceTokenXMDao.save(deviceToken);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<DeviceTokenXM> listByUid(Long uid) {
|
| | | return deviceTokenXMDao.listByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public DeviceTokenXM selectByDeviceActiveId(Long deviceActiveId) {
|
| | | return deviceTokenXMDao.selectByDeviceActiveId(deviceActiveId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<String> listRegId(int page, int count) {
|
| | | return deviceTokenXMDao.listRegId((page - 1) * count, count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countRegId() {
|
| | | return deviceTokenXMDao.countRegId();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void bindUid(Long deviceActiveId, Long uid) {
|
| | | DeviceTokenXM xm = selectByDeviceActiveId(deviceActiveId);
|
| | | if (xm != null) {
|
| | | xm.setUid(uid);
|
| | | xm.setUpdateTime(new Date());
|
| | | deviceTokenXMDao.save(xm);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void unBindUid(Long deviceActiveId) {
|
| | | DeviceTokenXM xm = selectByDeviceActiveId(deviceActiveId);
|
| | | if (xm != null) {
|
| | | xm.setUid(null);
|
| | | xm.setUpdateTime(new Date());
|
| | | deviceTokenXMDao.save(xm);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | private List<DeviceTokenHW> filterDeviceToken(List<DeviceTokenHW> hwDeviceList, int hour) {
|
| | | // TODO 暂时不处理消息免打扰
|
| | | if (1 > 0)
|
| | | return hwDeviceList;
|
| | | // 处理消息免打扰
|
| | | if (hour >= 20 || hour < 8) {
|
| | | Set<Long> uidSets = new HashSet<>();
|
| | |
| | |
|
| | | Calendar now = Calendar.getInstance();
|
| | | int hour = now.get(Calendar.HOUR_OF_DAY);
|
| | | if (hour >= 8 && hour < 20) {
|
| | | ispush = true; // 可推送
|
| | | } else {
|
| | | listNotPushId = validateNotDisturb();
|
| | | }
|
| | | // if (hour >= 8 && hour < 20) {
|
| | | // ispush = true; // 可推送
|
| | | // } else {
|
| | | // listNotPushId = validateNotDisturb();
|
| | | // }
|
| | | |
| | | ispush=true;//TODO 处理消息免打扰
|
| | |
|
| | | for (DeviceTokenIOS ios : list) {
|
| | |
|
| | |
| | | }
|
| | |
|
| | | private List<DeviceTokenOPPO> filterDeviceToken(List<DeviceTokenOPPO> deviceList, int hour) {
|
| | |
|
| | | // TODO 消息免打扰关闭
|
| | | if (1 > 0)
|
| | | return deviceList;
|
| | |
|
| | | // 处理消息免打扰
|
| | | if (hour >= 20 || hour < 8) {
|
| | | Set<Long> uidSets = new HashSet<>();
|
| | |
| | | }
|
| | |
|
| | | private List<DeviceTokenVIVO> filterDeviceToken(List<DeviceTokenVIVO> deviceList, int hour) {
|
| | | // TODO 消息免打扰关闭
|
| | | if (1 > 0)
|
| | | return deviceList;
|
| | | // 处理消息免打扰
|
| | | if (hour >= 20 || hour < 8) {
|
| | | Set<Long> uidSets = new HashSet<>();
|
| | |
| | | contentJson.put("id", id);
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("type",PushTypeEnum.ZNX.name());
|
| | | json.put("type", PushTypeEnum.ZNX.name());
|
| | | json.put("content", contentJson);
|
| | | json.put("miPushUrl", String.format("%s.ui.main.MainActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | | json.put("miPushUrl",
|
| | | String.format("%s.ui.main.MainActivity", Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | |
|
| | | // 版本推送
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | |
| | | JSONObject json = new JSONObject();
|
| | | json.put("type", PushTypeEnum.ZNX.name());
|
| | | json.put("content", contentJson);
|
| | | json.put("miPushUrl", String.format("%s.ui.main.MainActivity",
|
| | | Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | | json.put("miPushUrl",
|
| | | String.format("%s.ui.main.MainActivity", Constant.systemCommonConfig.getAndroidBaseactivityName()));
|
| | |
|
| | | // 版本推送
|
| | | if (versions != null && versions.trim().length() > 0) {
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.push;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenXM;
|
| | |
|
| | | /**
|
| | | * XM的设备绑定
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface DeviceTokenXMService {
|
| | |
|
| | | /**
|
| | | * 添加regId
|
| | | * |
| | | * @param deviceToken
|
| | | */
|
| | | public void addDeviceToken(DeviceTokenXM deviceToken);
|
| | |
|
| | | /**
|
| | | * 根据用户ID查询
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<DeviceTokenXM> listByUid(Long uid);
|
| | |
|
| | | /**
|
| | | * 根据DeviceActiveId查询
|
| | | * |
| | | * @param deviceActiveId
|
| | | * @return
|
| | | */
|
| | | public DeviceTokenXM selectByDeviceActiveId(Long deviceActiveId);
|
| | |
|
| | | /**
|
| | | * 根据最小更新时间查询
|
| | | * |
| | | * @param start
|
| | | * @param count
|
| | | * @param minUpdateTime
|
| | | * @return
|
| | | */
|
| | | public List<String> listRegId(int page, int count);
|
| | |
|
| | | /**
|
| | | * 根据最小更新时间查询
|
| | | * |
| | | * @param minUpdateTime
|
| | | * @return
|
| | | */
|
| | | public long countRegId();
|
| | |
|
| | | /**
|
| | | * 绑定用户ID
|
| | | * |
| | | * @param deviceActiveId
|
| | | * @param uid
|
| | | */
|
| | | public void bindUid(Long deviceActiveId, Long uid);
|
| | |
|
| | | /**
|
| | | * 解绑用户ID
|
| | | * |
| | | * @param uid
|
| | | */
|
| | | public void unBindUid(Long deviceActiveId);
|
| | |
|
| | | }
|
| | |
| | | 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());
|
| | |
| | | throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createWEEXPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushTypeEnum.baichuan.getCode()) {
|
| | | String shortUrl = HttpUtil.getShortLink(url);
|
| | | if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | throw new Exception("获取短链出错");
|
| | | String shortUrl = url;
|
| | | // HttpUtil.getShortLink(url);
|
| | | // if (StringUtil.isNullOrEmpty(shortUrl))
|
| | | // throw new Exception("获取短链出错");
|
| | | json = IOSPushFactory.createBaiChuanPush(shortUrl, info.getTitle(), info.getContent());
|
| | | } else if (type == PushTypeEnum.welfare.getCode()) {
|
| | | json = IOSPushFactory.createWelfarePush(info.getTitle(), info.getContent());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static int singlePushXiaoMiByRegisterId(MessageInfo info, JSONObject json, PushRecord pushRecord,
|
| | | String regId) {
|
| | | if (Constant.IS_TEST)
|
| | | return 1;
|
| | |
|
| | | JSONObject mapXm = JSONObject.fromObject(json);
|
| | |
|
| | | List<String> regIdList = new ArrayList<>();
|
| | | regIdList.add(regId);
|
| | | String android = XiaoMiPushUtil.pushBatchAndroidForXM(info, mapXm, regIdList);
|
| | |
|
| | | LogHelper.userInfo("安卓推送测试:" + android);
|
| | | pushRecord.setAndroidPushId(android);
|
| | |
|
| | | if (android != null) {
|
| | | return 1;
|
| | | } else {
|
| | | return 4;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * IOS 单推
|
| | | *
|
| | |
| | | package com.yeshi.fanli.util.push;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | |
| | | message = builder.build();
|
| | | try {
|
| | | Result result = sender.broadcastAll(message, 3);
|
| | | return result.getMessageId();// 成功 返回消息的Id, 失败返回null
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 批量推送
|
| | | * |
| | | * @param info
|
| | | * @param map
|
| | | * @param regList
|
| | | * 最大个数为1000
|
| | | * @return
|
| | | */
|
| | | public static String pushBatchAndroidForXM(MessageInfo info, Map<String, Object> map, List<String> regList) {
|
| | | if (Constant.IS_TEST)
|
| | | return null;
|
| | | if (regList == null || regList.size() == 0)
|
| | | return "";
|
| | |
|
| | | String name = info.getPackageName();
|
| | | if (!Constant.systemCommonConfig.getAndroidPackageName().equalsIgnoreCase(name)
|
| | | && !Constant.systemCommonConfig.getIosBundleId().equalsIgnoreCase(name)) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | // 从info中取页面传来的值
|
| | | Constants.useOfficial(); // 启动推送方法
|
| | | String PackageName = info.getPackageName();
|
| | | Sender sender = new Sender(XIAOMI_F_ANDROID_APP_SECERT); // 申请的AppSecert
|
| | | String title = info.getTitle();
|
| | | String payload = info.getContent();
|
| | | String description = info.getContent();
|
| | |
|
| | | Message message = null; // 做循环传来的key
|
| | | Builder builder = new Message.Builder().restrictedPackageName(PackageName).title(title).payload(payload)
|
| | | .description(description).passThrough(0) // 设置消息是否通过透传方式至App,
|
| | | // 1表示透传,0表示通知栏消息(默认)
|
| | | .notifyType(1); // 设置通知类型, type类型(1-默认提示音, 2-使用默认震动提示,
|
| | | // 3-使用默认led灯光提示)
|
| | | // 将extra放入MessageInfo对象中, 循环遍历extra中的key 和 value
|
| | | if (map != null) {
|
| | | for (String key : map.keySet()) {
|
| | | builder.extra(key, map.get(key).toString());
|
| | | }
|
| | | }
|
| | | message = builder.build();
|
| | | try {
|
| | | Result result = sender.send(message, regList, 3);
|
| | | return result.getMessageId();// 成功 返回消息的Id, 失败返回null
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | |
| | | // jsonXm 转换为 map
|
| | | JSONObject mapXm = JSONObject.fromObject(json);
|
| | | String android = allPushAndroidForXM(info, mapXm);
|
| | | LogHelper.userInfo("安卓推送测试:" + android);
|
| | | LogHelper.userInfo("小米推送:" + android);
|
| | | pushRecord.setAndroidPushId(android);
|
| | | if (android != null) {
|
| | | return 1;
|