11
11
import cn .jiguang .common .utils .Preconditions ;
12
12
import cn .jpush .api .push .model .PushModel ;
13
13
14
- public class Notification implements PushModel {
14
+ public class Notification implements PushModel {
15
+ private boolean aiOpportunity = false ;
15
16
private final Object alert ;
16
17
private final Set <PlatformNotification > notifications ;
17
18
18
- private Notification (Object alert , Set <PlatformNotification > notifications ) {
19
+ private Notification (boolean aiOpportunity , Object alert , Set <PlatformNotification > notifications ) {
20
+ this .aiOpportunity = aiOpportunity ;
19
21
this .alert = alert ;
20
22
this .notifications = notifications ;
21
23
}
22
24
23
25
public static Builder newBuilder () {
24
26
return new Builder ();
25
27
}
28
+
29
+ public static Notification aiOpportunity (boolean ai_opportunity ) {
30
+ return newBuilder ().setAiOpportunity (ai_opportunity ).build ();
31
+ }
26
32
27
33
/**
28
34
* Quick set all platform alert.
@@ -92,6 +98,8 @@ public static Notification winphone(String alert, Map<String, String> extras) {
92
98
93
99
public JsonElement toJSON () {
94
100
JsonObject json = new JsonObject ();
101
+ json .addProperty ("ai_opportunity" , aiOpportunity );
102
+
95
103
if (null != alert ) {
96
104
if (alert instanceof JsonObject ) {
97
105
json .add (PlatformNotification .ALERT , (JsonObject ) alert );
@@ -117,9 +125,15 @@ public JsonElement toJSON() {
117
125
}
118
126
119
127
public static class Builder {
128
+ private boolean aiOpportunity ;
120
129
private Object alert ;
121
130
private Set <PlatformNotification > builder ;
122
-
131
+
132
+ public Builder setAiOpportunity (boolean aiOpportunity ) {
133
+ this .aiOpportunity = aiOpportunity ;
134
+ return this ;
135
+ }
136
+
123
137
public Builder setAlert (Object alert ) {
124
138
this .alert = alert ;
125
139
return this ;
@@ -134,9 +148,9 @@ public Builder addPlatformNotification(PlatformNotification notification) {
134
148
}
135
149
136
150
public Notification build () {
137
- Preconditions .checkArgument (! (null == builder && null == alert ),
151
+ Preconditions .checkArgument (! (null == builder && null == alert ),
138
152
"No notification payload is set." );
139
- return new Notification (alert , builder );
153
+ return new Notification (aiOpportunity , alert , builder );
140
154
}
141
155
}
142
156
}
0 commit comments