Skip to content

Commit 144febf

Browse files
committed
Merge pull request #31 from jpush/dev
merge version 3.2.7
2 parents c9452ca + fa4ea58 commit 144febf

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
这是 JPush REST API 的 Java 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。
1010

11-
对应的 REST API 文档:<http://docs.jpush.cn/display/dev/REST+API>
11+
对应的 REST API 文档:<http://docs.jpush.io/server/server_overview/>
1212

1313
本开发包 Javadoc:[API Docs](http://jpush.github.io/jpush-api-java-client/apidocs/)
1414

src/main/java/cn/jpush/api/JPushClient.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import cn.jpush.api.schedule.model.SchedulePayload;
2828
import cn.jpush.api.schedule.model.TriggerPayload;
2929
import cn.jpush.api.utils.Preconditions;
30+
import com.google.gson.JsonObject;
3031

3132
import java.util.Map;
3233
import java.util.Set;
@@ -269,6 +270,28 @@ public PushResult sendIosNotificationWithAlias(IosAlert alert,
269270
.build();
270271
return _pushClient.sendPush(payload);
271272
}
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+
}
272295

273296
/**
274297
* Shortcut
@@ -306,6 +329,28 @@ public PushResult sendIosNotificationWithRegistrationID(IosAlert alert,
306329
return _pushClient.sendPush(payload);
307330
}
308331

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+
309354

310355
// ---------------------- shortcuts - message
311356

src/main/java/cn/jpush/api/device/OnlineStatus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public void setLast_online_time(String last_online_time) {
2424
@Override
2525
public String toString() {
2626
if(null == last_online_time) {
27-
return "OnlineStatus " + online;
27+
return "status: " + online;
2828
}
29-
return "OnlineStatus " + online + " ," + last_online_time;
29+
return "status: " + online + " , last_online_time: " + last_online_time;
3030
}
3131
}

src/main/java/cn/jpush/api/push/model/notification/IosAlert.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public JsonElement toJSON() {
3939
json.addProperty("title", title);
4040
}
4141

42-
if( StringUtils.isNotEmpty(title) ) {
42+
if( StringUtils.isNotEmpty(body) ) {
4343
json.addProperty("body", body);
4444
}
4545

src/main/java/cn/jpush/api/push/model/notification/PlatformNotification.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public JsonElement toJSON() {
4242
if ( alert instanceof JsonObject) {
4343
json.add(ALERT, (JsonObject) alert);
4444
} else if (alert instanceof IosAlert) {
45-
json.add(PlatformNotification.ALERT, ((IosAlert) alert).toJSON());
45+
json.add(ALERT, ((IosAlert) alert).toJSON());
4646
} else {
47-
json.add(PlatformNotification.ALERT, new JsonPrimitive(alert.toString()));
47+
json.add(ALERT, new JsonPrimitive(alert.toString()));
4848
}
4949
}
5050

0 commit comments

Comments
 (0)