|
|
@@ -0,0 +1,185 @@
|
|
|
+package com.usoftchina.uu.baidu.push.dto;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Android通知格式
|
|
|
+ *
|
|
|
+ * @author yingp
|
|
|
+ * @date 2019/4/19
|
|
|
+ */
|
|
|
+public class AndroidNotification implements Notification{
|
|
|
+ /**
|
|
|
+ * 通知标题,可以为空;如果为空则设为appid对应的应用名。
|
|
|
+ */
|
|
|
+ private String title;
|
|
|
+ /**
|
|
|
+ * 通知文本内容,不能为空。
|
|
|
+ */
|
|
|
+ private String description;
|
|
|
+ /**
|
|
|
+ * android客户端自定义通知样式,如果没有设置默认为0。
|
|
|
+ */
|
|
|
+ private Integer notification_builder_id = 0;
|
|
|
+ /**
|
|
|
+ * 只有notification_builder_id为0时有效,可以设置通知的基本样式包括(响铃:0x04;振动:0x02;可清除:0x01;),
|
|
|
+ * 这是一个flag整形,每一位代表一种样式,如果想选择任意两种或三种通知样式,notification_basic_style的值即为
|
|
|
+ * 对应样式数值相加后的值。
|
|
|
+ */
|
|
|
+ private Integer notification_basic_style = 7;
|
|
|
+ /**
|
|
|
+ * 点击通知后的行为(1:打开Url; 2:自定义行为;)。 open_type =0,只回调onNotificationClicked方法,不做其他操作;
|
|
|
+ * open_type = 1,url != null:打开网页; open_type = 2,pkg_content = null:直接打开应用;
|
|
|
+ * open_type = 2,pkg_content != null:自定义动作打开应用。
|
|
|
+ */
|
|
|
+ private Integer open_type = 0;
|
|
|
+ /**
|
|
|
+ * 需要打开的Url地址,open_type为1时才有效。
|
|
|
+ */
|
|
|
+ private String url;
|
|
|
+ /**
|
|
|
+ * open_type为2时才有效,Android端SDK会把pkg_content字符串转换成Android Intent,通过该Intent打开对应app组件,
|
|
|
+ * 所以pkg_content字符串格式必须遵循Intent uri格式,最简单的方法可以通过Intent方法toURI()获取。
|
|
|
+ */
|
|
|
+ private String pkg_content;
|
|
|
+ /**
|
|
|
+ * 自定义内容,键值对,Json对象形式(可选);在android客户端,这些键值对将以Intent中的extra进行传递。
|
|
|
+ */
|
|
|
+ private String custom_content;
|
|
|
+
|
|
|
+ private AndroidNotification() {
|
|
|
+ }
|
|
|
+
|
|
|
+ private AndroidNotification(String title, String description, Integer notification_builder_id, Integer notification_basic_style, Integer open_type, String url, String pkg_content, String custom_content) {
|
|
|
+ this.title = title;
|
|
|
+ this.description = description;
|
|
|
+ this.notification_builder_id = notification_builder_id;
|
|
|
+ this.notification_basic_style = notification_basic_style;
|
|
|
+ this.open_type = open_type;
|
|
|
+ this.url = url;
|
|
|
+ this.pkg_content = pkg_content;
|
|
|
+ this.custom_content = custom_content;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getTitle() {
|
|
|
+ return title;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setTitle(String title) {
|
|
|
+ this.title = title;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getDescription() {
|
|
|
+ return description;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setDescription(String description) {
|
|
|
+ this.description = description;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getNotification_builder_id() {
|
|
|
+ return notification_builder_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setNotification_builder_id(Integer notification_builder_id) {
|
|
|
+ this.notification_builder_id = notification_builder_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getNotification_basic_style() {
|
|
|
+ return notification_basic_style;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setNotification_basic_style(Integer notification_basic_style) {
|
|
|
+ this.notification_basic_style = notification_basic_style;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getOpen_type() {
|
|
|
+ return open_type;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setOpen_type(Integer open_type) {
|
|
|
+ this.open_type = open_type;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getUrl() {
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setUrl(String url) {
|
|
|
+ this.url = url;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getPkg_content() {
|
|
|
+ return pkg_content;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPkg_content(String pkg_content) {
|
|
|
+ this.pkg_content = pkg_content;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getCustom_content() {
|
|
|
+ return custom_content;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setCustom_content(String custom_content) {
|
|
|
+ this.custom_content = custom_content;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Builder newBuilder() {
|
|
|
+ return new Builder();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static class Builder {
|
|
|
+ private String title;
|
|
|
+ private String description;
|
|
|
+ private Integer notificationBuilderId = 0;
|
|
|
+ private Integer notificationBasicStyle = 7;
|
|
|
+ private Integer openType = 0;
|
|
|
+ private String url;
|
|
|
+ private String pkgContent;
|
|
|
+ private String customContent;
|
|
|
+
|
|
|
+ public Builder setTitle(String title) {
|
|
|
+ this.title = title;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setDescription(String description) {
|
|
|
+ this.description = description;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setNotificationBuilderId(Integer notificationBuilderId) {
|
|
|
+ this.notificationBuilderId = notificationBuilderId;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setNotificationBasicStyle(Integer notificationBasicStyle) {
|
|
|
+ this.notificationBasicStyle = notificationBasicStyle;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setOpenType(Integer openType) {
|
|
|
+ this.openType = openType;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setUrl(String url) {
|
|
|
+ this.url = url;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setPkgContent(String pkgContent) {
|
|
|
+ this.pkgContent = pkgContent;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder setCustomContent(String customContent) {
|
|
|
+ this.customContent = customContent;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public AndroidNotification build() {
|
|
|
+ return new AndroidNotification(title, description, notificationBuilderId, notificationBasicStyle,
|
|
|
+ openType, url, pkgContent, customContent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|