Message.php 1.7 KB

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