Skip to content

Commit

Permalink
Merge pull request #31 from jpush/dev
Browse files Browse the repository at this point in the history
merge version 3.2.7
  • Loading branch information
Liuchy1 committed Sep 11, 2015
2 parents c9452ca + fa4ea58 commit 144febf
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

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

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

Expand Down
45 changes: 45 additions & 0 deletions src/main/java/cn/jpush/api/JPushClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import cn.jpush.api.schedule.model.SchedulePayload;
import cn.jpush.api.schedule.model.TriggerPayload;
import cn.jpush.api.utils.Preconditions;
import com.google.gson.JsonObject;

import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -269,6 +270,28 @@ public PushResult sendIosNotificationWithAlias(IosAlert alert,
.build();
return _pushClient.sendPush(payload);
}

/**
* Send an iOS notification with alias.
* If you want to send alert as a Json object, maybe this method is what you needed.
*
* @param alert The wrapper of APNs alert.
* @param extras The extra params.
* @param alias The alias list.
* @return
* @throws APIConnectionException
* @throws APIRequestException
*/
public PushResult sendIosNotificationWithAlias(JsonObject alert,
Map<String, String> extras, String... alias)
throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.newBuilder()
.setPlatform(Platform.ios())
.setAudience(Audience.alias(alias))
.setNotification(Notification.ios(alert, extras))
.build();
return _pushClient.sendPush(payload);
}

/**
* Shortcut
Expand Down Expand Up @@ -306,6 +329,28 @@ public PushResult sendIosNotificationWithRegistrationID(IosAlert alert,
return _pushClient.sendPush(payload);
}

/**
* Send an iOS notification with registrationIds.
* If you want to send alert as a Json object, maybe this method is what you needed.
*
* @param alert The wrapper of APNs alert.
* @param extras The extra params.
* @param registrationID The registration ids.
* @return
* @throws APIConnectionException
* @throws APIRequestException
*/
public PushResult sendIosNotificationWithRegistrationID(JsonObject alert,
Map<String, String> extras, String... registrationID)
throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.newBuilder()
.setPlatform(Platform.ios())
.setAudience(Audience.registrationId(registrationID))
.setNotification(Notification.ios(alert, extras))
.build();
return _pushClient.sendPush(payload);
}


// ---------------------- shortcuts - message

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/jpush/api/device/OnlineStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public void setLast_online_time(String last_online_time) {
@Override
public String toString() {
if(null == last_online_time) {
return "OnlineStatus " + online;
return "status: " + online;
}
return "OnlineStatus " + online + " ," + last_online_time;
return "status: " + online + " , last_online_time: " + last_online_time;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public JsonElement toJSON() {
json.addProperty("title", title);
}

if( StringUtils.isNotEmpty(title) ) {
if( StringUtils.isNotEmpty(body) ) {
json.addProperty("body", body);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public JsonElement toJSON() {
if ( alert instanceof JsonObject) {
json.add(ALERT, (JsonObject) alert);
} else if (alert instanceof IosAlert) {
json.add(PlatformNotification.ALERT, ((IosAlert) alert).toJSON());
json.add(ALERT, ((IosAlert) alert).toJSON());
} else {
json.add(PlatformNotification.ALERT, new JsonPrimitive(alert.toString()));
json.add(ALERT, new JsonPrimitive(alert.toString()));
}
}

Expand Down

0 comments on commit 144febf

Please sign in to comment.