|
27 | 27 | import cn.jpush.api.schedule.model.SchedulePayload; |
28 | 28 | import cn.jpush.api.schedule.model.TriggerPayload; |
29 | 29 | import cn.jpush.api.utils.Preconditions; |
| 30 | +import com.google.gson.JsonObject; |
30 | 31 |
|
31 | 32 | import java.util.Map; |
32 | 33 | import java.util.Set; |
@@ -269,6 +270,28 @@ public PushResult sendIosNotificationWithAlias(IosAlert alert, |
269 | 270 | .build(); |
270 | 271 | return _pushClient.sendPush(payload); |
271 | 272 | } |
| 273 | + |
| 274 | + /** |
| 275 | + * Send an iOS notification with alias. |
| 276 | + * If you want to send alert as a Json object, maybe this method is what you needed. |
| 277 | + * |
| 278 | + * @param alert The wrapper of APNs alert. |
| 279 | + * @param extras The extra params. |
| 280 | + * @param alias The alias list. |
| 281 | + * @return |
| 282 | + * @throws APIConnectionException |
| 283 | + * @throws APIRequestException |
| 284 | + */ |
| 285 | + public PushResult sendIosNotificationWithAlias(JsonObject alert, |
| 286 | + Map<String, String> extras, String... alias) |
| 287 | + throws APIConnectionException, APIRequestException { |
| 288 | + PushPayload payload = PushPayload.newBuilder() |
| 289 | + .setPlatform(Platform.ios()) |
| 290 | + .setAudience(Audience.alias(alias)) |
| 291 | + .setNotification(Notification.ios(alert, extras)) |
| 292 | + .build(); |
| 293 | + return _pushClient.sendPush(payload); |
| 294 | + } |
272 | 295 |
|
273 | 296 | /** |
274 | 297 | * Shortcut |
@@ -306,6 +329,28 @@ public PushResult sendIosNotificationWithRegistrationID(IosAlert alert, |
306 | 329 | return _pushClient.sendPush(payload); |
307 | 330 | } |
308 | 331 |
|
| 332 | + /** |
| 333 | + * Send an iOS notification with registrationIds. |
| 334 | + * If you want to send alert as a Json object, maybe this method is what you needed. |
| 335 | + * |
| 336 | + * @param alert The wrapper of APNs alert. |
| 337 | + * @param extras The extra params. |
| 338 | + * @param registrationID The registration ids. |
| 339 | + * @return |
| 340 | + * @throws APIConnectionException |
| 341 | + * @throws APIRequestException |
| 342 | + */ |
| 343 | + public PushResult sendIosNotificationWithRegistrationID(JsonObject alert, |
| 344 | + Map<String, String> extras, String... registrationID) |
| 345 | + throws APIConnectionException, APIRequestException { |
| 346 | + PushPayload payload = PushPayload.newBuilder() |
| 347 | + .setPlatform(Platform.ios()) |
| 348 | + .setAudience(Audience.registrationId(registrationID)) |
| 349 | + .setNotification(Notification.ios(alert, extras)) |
| 350 | + .build(); |
| 351 | + return _pushClient.sendPush(payload); |
| 352 | + } |
| 353 | + |
309 | 354 |
|
310 | 355 | // ---------------------- shortcuts - message |
311 | 356 |
|
|
0 commit comments