Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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