JiGuangPushService.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //package com.ruoyi.common.jpush;
  2. //
  3. //import cn.jiguang.sdk.api.PushApi;
  4. //import cn.jiguang.sdk.bean.push.PushSendParam;
  5. //import cn.jiguang.sdk.bean.push.PushSendResult;
  6. //import cn.jiguang.sdk.bean.push.audience.Audience;
  7. //import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
  8. //import cn.jiguang.sdk.bean.push.other.CidGetResult;
  9. //import cn.jiguang.sdk.constants.ApiConstants;
  10. //import com.alibaba.fastjson.JSON;
  11. //import org.slf4j.Logger;
  12. //import org.slf4j.LoggerFactory;
  13. //import org.springframework.beans.factory.annotation.Autowired;
  14. //import org.springframework.stereotype.Service;
  15. //
  16. //import java.util.Arrays;
  17. //
  18. //@Service
  19. //public class JiGuangPushService {
  20. // Logger log = LoggerFactory.getLogger(this.getClass());
  21. //
  22. //
  23. // @Autowired
  24. // private PushApi pushApi;
  25. //
  26. // public void getCidForPush() {
  27. // CidGetResult result = pushApi.getCidForPush(10);
  28. // log.info("result:{}", result);
  29. // }
  30. //
  31. //
  32. // public void send(String title, String alert, String alias) {
  33. // PushSendParam param = new PushSendParam();
  34. // // 通知内容
  35. // NotificationMessage.Android android = new NotificationMessage.Android();
  36. // android.setAlert(alert);
  37. // android.setTitle(title);
  38. // NotificationMessage.Android.Intent intent = new NotificationMessage.Android.Intent();
  39. // intent.setUrl("intent:#Intent;action=android.intent.action.MAIN;end");
  40. //
  41. // android.setIntent(intent);
  42. //
  43. // NotificationMessage notificationMessage = new NotificationMessage();
  44. // notificationMessage.setAlert(alert);
  45. // notificationMessage.setAndroid(android);
  46. // param.setNotification(notificationMessage);
  47. //
  48. // // 目标人群
  49. // Audience audience = new Audience();
  50. // audience.setAliasList(Arrays.asList(alias));
  51. //// audience.setRegistrationIdList(Arrays.asList("1104a89793af2cfc030", "1104a89793af2cfc030"));
  52. // // 指定目标
  53. // param.setAudience(audience);
  54. // // 或者发送所有人
  55. //// param.setAudience(ApiConstants.Audience.ALL);
  56. //
  57. // // 指定平台
  58. //// param.setPlatform(Arrays.asList(Platform.android, Platform.ios));
  59. // // 或者发送所有平台
  60. // param.setPlatform(ApiConstants.Platform.ANDROID);
  61. //
  62. // log.info("param:{}", JSON.toJSONString(param));
  63. // // 发送
  64. // try {
  65. // PushSendResult result = pushApi.send(param);
  66. // System.out.println("Push result: " + result);
  67. // } catch (Exception e) {
  68. // e.printStackTrace();
  69. // }
  70. //
  71. // }
  72. //
  73. //}