1111import cn .jiguang .common .utils .Preconditions ;
1212import cn .jpush .api .push .model .PushModel ;
1313
14- public class Notification implements PushModel {
14+ public class Notification implements PushModel {
15+ private boolean aiOpportunity = false ;
1516 private final Object alert ;
1617 private final Set <PlatformNotification > notifications ;
1718
18- private Notification (Object alert , Set <PlatformNotification > notifications ) {
19+ private Notification (boolean aiOpportunity , Object alert , Set <PlatformNotification > notifications ) {
20+ this .aiOpportunity = aiOpportunity ;
1921 this .alert = alert ;
2022 this .notifications = notifications ;
2123 }
2224
2325 public static Builder newBuilder () {
2426 return new Builder ();
2527 }
28+
29+ public static Notification aiOpportunity (boolean ai_opportunity ) {
30+ return newBuilder ().setAiOpportunity (ai_opportunity ).build ();
31+ }
2632
2733 /**
2834 * Quick set all platform alert.
@@ -92,6 +98,8 @@ public static Notification winphone(String alert, Map<String, String> extras) {
9298
9399 public JsonElement toJSON () {
94100 JsonObject json = new JsonObject ();
101+ json .addProperty ("ai_opportunity" , aiOpportunity );
102+
95103 if (null != alert ) {
96104 if (alert instanceof JsonObject ) {
97105 json .add (PlatformNotification .ALERT , (JsonObject ) alert );
@@ -117,9 +125,15 @@ public JsonElement toJSON() {
117125 }
118126
119127 public static class Builder {
128+ private boolean aiOpportunity ;
120129 private Object alert ;
121130 private Set <PlatformNotification > builder ;
122-
131+
132+ public Builder setAiOpportunity (boolean aiOpportunity ) {
133+ this .aiOpportunity = aiOpportunity ;
134+ return this ;
135+ }
136+
123137 public Builder setAlert (Object alert ) {
124138 this .alert = alert ;
125139 return this ;
@@ -134,9 +148,9 @@ public Builder addPlatformNotification(PlatformNotification notification) {
134148 }
135149
136150 public Notification build () {
137- Preconditions .checkArgument (! (null == builder && null == alert ),
151+ Preconditions .checkArgument (! (null == builder && null == alert ),
138152 "No notification payload is set." );
139- return new Notification (alert , builder );
153+ return new Notification (aiOpportunity , alert , builder );
140154 }
141155 }
142156}
0 commit comments