Message.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * 消息体.
  4. * @author wangkuiwei
  5. * @name Message
  6. * @desc 构建要发送的消息内容。
  7. *
  8. */
  9. namespace App\Libs\Push\XMPush;
  10. class Message {
  11. const EXTRA_PREFIX = 'extra.';
  12. const APS_PROPER_FIELDS_PREFIX = 'aps_proper_fields.';
  13. const HYBRID_PUSH_ACTION = "push_server_action";
  14. const HYBRID_ACTION_MESSAGE = "hybrid_message";
  15. const HYBRID_DEBUG = "hybrid_debug";
  16. const HYBRID_PATH = "hybrid_pn";
  17. protected $payload; //消息内容
  18. protected $restricted_package_name; //支持多包名
  19. protected $pass_through; //是否透传给app(1 透传 0 通知栏信息)
  20. protected $notify_type; //通知类型 可组合 (-1 Default_all,1 Default_sound,2 Default_vibrate(震动),4 Default_lights)
  21. protected $notify_id; //0-4同一个notifyId在通知栏只会保留一条
  22. protected $extra; //可选项,额外定义一些key value(字符不能超过1024,key不能超过10个)
  23. protected $description; //在通知栏的描述,长度小于128
  24. protected $title; //在通知栏的标题,长度小于16
  25. protected $time_to_live; //可选项,当用户离线是,消息保留时间,默认两周,单位ms
  26. protected $time_to_send; //可选项,定时发送消息,用自1970年1月1日以来00:00:00.0 UTC时间表示(以毫秒为单位的时间)。
  27. protected $fields; //含有本条消息所有属性的数组
  28. protected $json_infos;
  29. /* IOS 使用 */
  30. protected $sound_url; //可选,消息铃声
  31. protected $badge; //可选,自定义通知数字角标
  32. public function __construct() {
  33. $this->extra = array();
  34. $this->fields = array();
  35. }
  36. public function getFields() {
  37. return $this->fields;
  38. }
  39. public function getJSONInfos() {
  40. return $this->json_infos;
  41. }
  42. }
  43. ?>