@@ -55,6 +55,7 @@ private static void checkArgument(boolean expression, Object errorMessage) {
55
55
private ParseQuery <ParseInstallation > query ;
56
56
private Long expirationTime ;
57
57
private Long expirationTimeInterval ;
58
+ private Long pushTime ;
58
59
private Boolean pushToIOS ;
59
60
private Boolean pushToAndroid ;
60
61
private JSONObject data ;
@@ -96,6 +97,18 @@ public Builder expirationTimeInterval(Long expirationTimeInterval) {
96
97
return this ;
97
98
}
98
99
100
+ public Builder pushTime (Long pushTime ) {
101
+ if (pushTime != null ) {
102
+ long now = System .currentTimeMillis () / 1000 ;
103
+ long twoWeeks = 60 *60 *24 *7 *2 ;
104
+ checkArgument (pushTime > now , "Scheduled push time can not be in the past" );
105
+ checkArgument (pushTime < now + twoWeeks , "Scheduled push time can not be more than " +
106
+ "two weeks in the future" );
107
+ }
108
+ this .pushTime = pushTime ;
109
+ return this ;
110
+ }
111
+
99
112
public Builder pushToIOS (Boolean pushToIOS ) {
100
113
checkArgument (query == null , "Cannot set push targets (i.e. setPushToAndroid or " +
101
114
"setPushToIOS) when pushing to a query" );
@@ -151,6 +164,7 @@ public State build() {
151
164
private final ParseQuery .State <ParseInstallation > queryState ;
152
165
private final Long expirationTime ;
153
166
private final Long expirationTimeInterval ;
167
+ private final Long pushTime ;
154
168
private final Boolean pushToIOS ;
155
169
private final Boolean pushToAndroid ;
156
170
private final JSONObject data ;
@@ -161,6 +175,7 @@ private State(Builder builder) {
161
175
this .queryState = builder .query == null ? null : builder .query .getBuilder ().build ();
162
176
this .expirationTime = builder .expirationTime ;
163
177
this .expirationTimeInterval = builder .expirationTimeInterval ;
178
+ this .pushTime = builder .pushTime ;
164
179
this .pushToIOS = builder .pushToIOS ;
165
180
this .pushToAndroid = builder .pushToAndroid ;
166
181
// Since in builder.build() we check data is not null, we do not need to check it again here.
@@ -189,6 +204,10 @@ public Long expirationTimeInterval() {
189
204
return expirationTimeInterval ;
190
205
}
191
206
207
+ public Long pushTime () {
208
+ return pushTime ;
209
+ }
210
+
192
211
public Boolean pushToIOS () {
193
212
return pushToIOS ;
194
213
}
@@ -421,6 +440,14 @@ public void clearExpiration() {
421
440
builder .expirationTimeInterval (null );
422
441
}
423
442
443
+ /**
444
+ * Sets a UNIX epoch timestamp at which this notification should be delivered, in seconds (UTC).
445
+ * Scheduled time can not be in the past and must be at most two weeks in the future.
446
+ */
447
+ public void setPushTime (long time ) {
448
+ builder .pushTime (time );
449
+ }
450
+
424
451
/**
425
452
* Set whether this push notification will go to iOS devices.
426
453
* <p/>
0 commit comments