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
25 changes: 5 additions & 20 deletions src/main/java/cn/jpush/api/JPushClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,7 @@ public PushResult sendIosNotificationWithRegistrationID(JsonObject alert, SMS sm


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

/**
* Shortcut
*/

public PushResult sendMessageAll(String msgContent) throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.messageAll(msgContent);
return _pushClient.sendPush(payload);
Expand All @@ -616,10 +613,7 @@ public PushResult sendMessageAll(String msgContent, SMS sms) throws APIConnectio
PushPayload payload = PushPayload.messageAll(msgContent, sms);
return _pushClient.sendPush(payload);
}

/**
* Shortcut
*/

public PushResult sendAndroidMessageWithAlias(String title, String msgContent, String... alias)
throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.newBuilder()
Expand Down Expand Up @@ -658,10 +652,7 @@ public PushResult sendAndroidMessageWithAlias(String title, String msgContent, S
.build();
return _pushClient.sendPush(payload);
}

/**
* Shortcut
*/

public PushResult sendAndroidMessageWithRegistrationID(String title, String msgContent, String... registrationID)
throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.newBuilder()
Expand Down Expand Up @@ -700,10 +691,7 @@ public PushResult sendAndroidMessageWithRegistrationID(String title, String msgC
.build();
return _pushClient.sendPush(payload);
}

/**
* Shortcut
*/

public PushResult sendIosMessageWithAlias(String title, String msgContent, String... alias)
throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.newBuilder()
Expand Down Expand Up @@ -742,7 +730,7 @@ public PushResult sendIosMessageWithAlias(String title, String msgContent, SMS s
.build();
return _pushClient.sendPush(payload);
}

public PushResult sendIosMessageWithRegistrationID(String title, String msgContent, String... registrationID)
throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.newBuilder()
Expand Down Expand Up @@ -782,9 +770,6 @@ public PushResult sendIosMessageWithRegistrationID(String title, String msgConte
return _pushClient.sendPush(payload);
}

/**
* Shortcut
*/
public PushResult sendMessageWithRegistrationID(String title, String msgContent, String... registrationID)
throws APIConnectionException, APIRequestException {
PushPayload payload = PushPayload.newBuilder()
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/cn/jpush/api/push/model/PushPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,19 @@ private PushPayload(Platform platform, Audience audience,
this.options = options;
this.sms = sms;
}

/**
* The entrance for building a PushPayload object.
* @return PushPayload builder
*/
public static Builder newBuilder() {
return new Builder();
}

/**
* The shortcut of building a simple alert notification object to all platforms and all audiences
* @param alert The alert message.
* @return PushPayload
*/
public static PushPayload alertAll(String alert) {
return new Builder()
Expand All @@ -80,6 +83,8 @@ public static PushPayload alertAll(String alert, SMS sms) {

/**
* The shortcut of building a simple message object to all platforms and all audiences
* @param msgContent The message content.
* @return PushPayload
*/
public static PushPayload messageAll(String msgContent) {
return new Builder()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/jpush/api/push/model/SMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static Builder newBuilder() {
*
* @param content The SMS content.
* @param delayTime The seconds you want to delay, should be greater than or equal to 0.
* @return
* @return SMS payload.
*/
public static SMS content(String content, int delayTime) {
return new Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
* APNs 通知类
* <p>
* 支持 APNs 默认的几个参数:
* <ul>
* <li>alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。</li>
* <li>badge: 支持 setBadge(int) 方法来设置;支持 incrBadge(int) 方法来增加。</li>
* <li>sound: 支持 setSound(string) 方法来设置声音文件。</li>
* <li>content-available: 用来支持后台推送。如果该值赋值为 1,表示开启后台推送。</li>
* <li>extras: JSON object. 支持更多的自定义字段信息。</li>
* </ul>
* </p>
* <p>
* 需要特别留意的是,JPush SDK 会对以下几个值有特别的默认设置考虑:
* <ul>
* <li>badge: 默认为 "+1"。如果需要取消 badge 值,需要显式地调用 disableBadge().</li>
* <li>sound: 默认为 "",即默认的声音提示。如果需要取消 sound 值,即不要声音,需要显式地调用 disableSound(). </li>
* </ul>
* </p>
*/
public class IosNotification extends PlatformNotification {
Expand Down Expand Up @@ -152,6 +156,7 @@ public Builder setBadge(int badge) {

/**
* equals to: +1
* @return IosNotification builder
*/
public Builder autoBadge() {
return incrBadge(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public static Builder newBuilder() {
public static Notification alert(Object alert) {
return newBuilder().setAlert(alert).build();
}

/**
* shortcut
*/

public static Notification android(String alert, String title, Map<String, String> extras) {
return newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
Expand All @@ -46,10 +43,7 @@ public static Notification android(String alert, String title, Map<String, Strin
.build())
.build();
}

/**
* shortcut
*/

public static Notification ios(Object alert, Map<String, String> extras) {
return newBuilder()
.addPlatformNotification(IosNotification.newBuilder()
Expand All @@ -58,10 +52,7 @@ public static Notification ios(Object alert, Map<String, String> extras) {
.build())
.build();
}

/**
* shortcut
*/

public static Notification ios_auto_badge() {
return newBuilder()
.addPlatformNotification(IosNotification.newBuilder()
Expand All @@ -70,10 +61,7 @@ public static Notification ios_auto_badge() {
.build())
.build();
}

/**
* shortcut
*/

public static Notification ios_set_badge(int badge) {
return newBuilder()
.addPlatformNotification(IosNotification.newBuilder()
Expand All @@ -82,10 +70,7 @@ public static Notification ios_set_badge(int badge) {
.build())
.build();
}

/**
* shortcut
*/

public static Notification ios_incr_badge(int badge) {
return newBuilder()
.addPlatformNotification(IosNotification.newBuilder()
Expand All @@ -94,10 +79,7 @@ public static Notification ios_incr_badge(int badge) {
.build())
.build();
}

/**
* shortcut
*/

public static Notification winphone(String alert, Map<String, String> extras) {
return newBuilder()
.addPlatformNotification(WinphoneNotification.newBuilder()
Expand Down