Skip to content

Commit

Permalink
update version to 3.7.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
wicked_tc130 committed May 29, 2024
1 parent 41d9ef8 commit 48578be
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 202 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.7.6</version>
<version>3.7.7</version>
<packaging>jar</packaging>
<url>https://github.com/jpush/jpush-api-java-client</url>
<name>JPush API Java Client</name>
Expand Down Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jiguang-common</artifactId>
<version>1.2.6</version>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/jpush/api/push/model/Notification3rd.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* 使用说明
* notification_3rd 只针对开通了厂商通道的用户生效;
* notification 和 notification_3rd 不能同时有内容,如果这两块同时有内容,则会返回错误提示;
* notification_3rd 的内容对 iOS 和 WinPhone 平台无效,只针对 Android 平台生效;
* notification_3rd 的内容对 iOS 和 HMOS 平台无效,只针对 Android 平台生效;
* notification_3rd 是用作补发厂商通知的内容,只有当 message 部分有内容,才允许传递此字段,且要两者都不为空时,才会对离线的厂商设备转发厂商通道的通知。
*/
public class Notification3rd implements PushModel{
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/cn/jpush/api/push/model/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform
*
* JPush 当前支持 Android, iOS, QuickApp,Windows Phone 四个平台的推送。其关键字分别为:"android", "ios", "quickapp","winphone"。
* JPush 当前支持 Android, iOS, QuickApp, HMOS 四个平台的推送。其关键字分别为:"android", "ios", "quickapp","hmos"。
* 使用方法,只需要在PushPayload中调用setPlatform方法。如:setPlatform(Platform.android_ios())
* 如需要全平台推送,只需要setPlatform(Platform.all())
*/
Expand Down Expand Up @@ -47,8 +47,8 @@ public static Platform quickapp() {
return newBuilder().addDeviceType(DeviceType.QuickApp).build();
}

public static Platform winphone() {
return newBuilder().addDeviceType(DeviceType.WinPhone).build();
public static Platform hmos() {
return newBuilder().addDeviceType(DeviceType.HMOS).build();
}

public static Platform android_ios() {
Expand All @@ -58,17 +58,17 @@ public static Platform android_ios() {
.build();
}

public static Platform android_winphone() {
public static Platform android_hmos() {
return newBuilder()
.addDeviceType(DeviceType.Android)
.addDeviceType(DeviceType.WinPhone)
.addDeviceType(DeviceType.HMOS)
.build();
}

public static Platform ios_winphone() {
public static Platform ios_hmos() {
return newBuilder()
.addDeviceType(DeviceType.IOS)
.addDeviceType(DeviceType.WinPhone)
.addDeviceType(DeviceType.HMOS)
.build();
}

Expand All @@ -86,10 +86,10 @@ public static Platform ios_quickapp() {
.build();
}

public static Platform quickapp_winphone() {
public static Platform quickapp_hmos() {
return newBuilder()
.addDeviceType(DeviceType.QuickApp)
.addDeviceType(DeviceType.WinPhone)
.addDeviceType(DeviceType.HMOS)
.build();
}

Expand All @@ -101,27 +101,27 @@ public static Platform android_ios_quickapp() {
.build();
}

public static Platform android_ios_winphone() {
public static Platform android_ios_hmos() {
return newBuilder()
.addDeviceType(DeviceType.Android)
.addDeviceType(DeviceType.IOS)
.addDeviceType(DeviceType.WinPhone)
.addDeviceType(DeviceType.HMOS)
.build();
}

public static Platform android_quickapp_winphone() {
public static Platform android_quickapp_hmos() {
return newBuilder()
.addDeviceType(DeviceType.Android)
.addDeviceType(DeviceType.QuickApp)
.addDeviceType(DeviceType.WinPhone)
.addDeviceType(DeviceType.HMOS)
.build();
}

public static Platform ios_quickapp_winphone() {
public static Platform ios_quickapp_hmos() {
return newBuilder()
.addDeviceType(DeviceType.IOS)
.addDeviceType(DeviceType.QuickApp)
.addDeviceType(DeviceType.WinPhone)
.addDeviceType(DeviceType.HMOS)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package cn.jpush.api.push.model.notification;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;

import java.util.Map;

/**
* <p><b>HMOS Phone 通知类</b></p>
* <br>
* 具体使用方法请参考官方文档 https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform
* 支持 HMOS Notification 的参数:
* <ul>
* <li>alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。</li>
* <li>title: 支持 setTitle(string) 方法来设置;可替换通知标题。 </li>
* <li>_open_page: 支持 setOpenPage(String) 方法来设置;可设置点击打开的页面名称</li>
* <li>extras: 继承自父类 PlatformNotification 的 extras 属性;支持通过 addExtra(key, value) 来添加自定义字段,具体看代码。 </li>
* </ul>
* <br>
*/
public class HmosNotification extends PlatformNotification {
private static final String NOTIFICATION_HMOS = "hmos";

private static final String TITLE = "title";
private static final String CATEGORY = "category";
private static final String LARGE_ICON = "large_icon";
private static final String INTENT = "intent";
private static final String BADGE_ADD_NUM = "badge_add_num";
private static final String TEST_MESSAGE = "test_message";
private static final String RECEIPT_ID = "receipt_id";

private final String title;
private final String category;
private final String large_icon;
private final JsonObject intent;
private final Integer badge_add_num;
private final Boolean test_message;
private final String receipt_id;

private HmosNotification(Object alert,
String title,
String category,
String large_icon,
JsonObject intent,
Integer badge_add_num,
Boolean test_message,
String receipt_id,
Map<String, String> extras,
Map<String, Number> numberExtras,
Map<String, Boolean> booleanExtras,
Map<String, JsonObject> jsonExtras,
Map<String, JsonPrimitive> customData) {
super(alert, extras, numberExtras, booleanExtras, jsonExtras, customData);

this.title = title;
this.category = category;
this.large_icon = large_icon;
this.intent = intent;
this.badge_add_num = badge_add_num;
this.test_message = test_message;
this.receipt_id = receipt_id;
}

public static Builder newBuilder() {
return new Builder();
}

public static HmosNotification alert(String alert) {
return newBuilder().setAlert(alert).build();
}


@Override
public String getPlatform() {
return NOTIFICATION_HMOS;
}

@Override
public JsonElement toJSON() {
JsonObject json = super.toJSON().getAsJsonObject();

if (null != title) {
json.add(TITLE, new JsonPrimitive(title));
}
if (null != category) {
json.add(CATEGORY, new JsonPrimitive(category));
}
if (null != large_icon) {
json.add(LARGE_ICON, new JsonPrimitive(large_icon));
}
if (null != intent) {
json.add(INTENT, intent);
}
if (null != badge_add_num) {
json.add(BADGE_ADD_NUM, new JsonPrimitive(badge_add_num));
}
if (null != test_message) {
json.add(TEST_MESSAGE, new JsonPrimitive(test_message));
}
if (null != receipt_id) {
json.add(RECEIPT_ID, new JsonPrimitive(receipt_id));
}
return json;
}


public static class Builder extends PlatformNotification.Builder<HmosNotification, Builder> {
private String title;
private String category;
private String large_icon;
private JsonObject intent;
private Integer badge_add_num;
private Boolean test_message;
private String receipt_id;

@Override
protected Builder getThis() {
return this;
}

@Override
public Builder setAlert(Object alert) {
this.alert = alert;
return this;
}

public Builder setTitle(String title) {
this.title = title;
return this;
}

public Builder setCategory(String category) {
this.category = category;
return this;
}

public Builder setLarge_icon(String large_icon) {
this.large_icon = large_icon;
return this;
}

public Builder setIntent(JsonObject intent) {
this.intent = intent;
return this;
}

public Builder setBadge_add_num(Integer badge_add_num) {
this.badge_add_num = badge_add_num;
return this;
}

public Builder setTest_message(Boolean test_message) {
this.test_message = test_message;
return this;
}

public Builder setReceipt_id(String receipt_id) {
this.receipt_id = receipt_id;
return this;
}

public HmosNotification build() {
return new HmosNotification(alert, title, category,large_icon,intent,badge_add_num,test_message,receipt_id,
extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder, super.customData);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ public static Notification ios_incr_badge(int badge) {
.build();
}

public static Notification winphone(String alert, Map<String, String> extras) {
public static Notification hmos(String alert, String title, Map<String, String> extras) {
return newBuilder()
.addPlatformNotification(WinphoneNotification.newBuilder()
.addPlatformNotification(HmosNotification.newBuilder()
.setAlert(alert)
.setTitle(title)
.addExtras(extras)
.build())
.build();
Expand Down
Loading

0 comments on commit 48578be

Please sign in to comment.