NIMSDK-AOS  9.19.0
SignallingPushConfig.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.avsignalling.model;
2 
3 
4 import com.netease.nimlib.session.MsgHelper;
5 
6 import java.io.Serializable;
7 import java.util.Map;
8 
9 /**
10  * 信令推送配置项
11  */
12 public class SignallingPushConfig implements Serializable {
13 
14  private final boolean needPush;
15 
16  private boolean needBadge = true;
17  private String pushTitle;
18  private String pushContent;
19  private String pushPayload;
20 
21  /**
22  * @param needPush 是否需要push
23  * @param pushTitle 推送标题
24  * @param pushContent 推送内容
25  */
26  public SignallingPushConfig(boolean needPush, String pushTitle, String pushContent) {
27  this.needPush = needPush;
28  this.pushTitle = pushTitle;
29  this.pushContent = pushContent;
30  }
31 
32  /**
33  * @param needPush 是否需要push
34  * @param pushTitle 推送标题
35  * @param pushContent 推送内容
36  * @param pushPayload 推送扩展 ,不需要的话填null
37  */
38  public SignallingPushConfig(boolean needPush, String pushTitle, String pushContent, Map<String, Object> pushPayload) {
39  this(needPush, pushTitle, pushContent);
40  this.pushPayload = MsgHelper.getJsonStringFromMap(pushPayload);
41  }
42 
43  /**
44  * 是否需要push
45  */
46  public boolean needPush() {
47  return needPush;
48  }
49 
50  public boolean needBadge() {
51  return needBadge;
52  }
53 
54  /**
55  * 获取推送标题
56  */
57  public String getPushTitle() {
58  return pushTitle;
59  }
60 
61  /**
62  * 获取推送内容
63  */
64  public String getPushContent() {
65  return pushContent;
66  }
67 
68  /**
69  * 获取推送扩展
70  */
71  public String getPushPayload() {
72  return pushPayload;
73  }
74 
75 
76  public static final class SignallingPushConfigBuilder {
77  private final boolean needPush;
78  private boolean needBadge = true;
79  private String pushTitle;
80  private String pushContent;
81  private String pushPayload;
82 
83  public SignallingPushConfigBuilder(boolean needPush) {
84  this.needPush = needPush;
85  }
86 
87  public SignallingPushConfigBuilder withNeedBadge(boolean needBadge) {
88  this.needBadge = needBadge;
89  return this;
90  }
91 
92  public SignallingPushConfigBuilder withPushTitle(String pushTitle) {
93  this.pushTitle = pushTitle;
94  return this;
95  }
96 
97  public SignallingPushConfigBuilder withPushContent(String pushContent) {
98  this.pushContent = pushContent;
99  return this;
100  }
101 
102  public SignallingPushConfigBuilder withPushPayload(String pushPayload) {
103  this.pushPayload = pushPayload;
104  return this;
105  }
106 
107  public SignallingPushConfig build() {
108  SignallingPushConfig signallingPushConfig = new SignallingPushConfig(needPush, pushTitle, pushContent);
109  signallingPushConfig.pushPayload = this.pushPayload;
110  signallingPushConfig.needBadge = this.needBadge;
111  return signallingPushConfig;
112  }
113  }
114 }
SignallingPushConfig(boolean needPush, String pushTitle, String pushContent)
SignallingPushConfig(boolean needPush, String pushTitle, String pushContent, Map< String, Object > pushPayload)