diff --git a/README.md b/README.md index 709150c..c769731 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,13 @@ ## 1. 集成 引入sdk包 ```xml - + io.github.jpush jiguang-sdk - 5.0.6 + 5.0.7 ``` diff --git a/example-for-spring/pom.xml b/example-for-spring/pom.xml index bec744d..bac851a 100644 --- a/example-for-spring/pom.xml +++ b/example-for-spring/pom.xml @@ -13,7 +13,7 @@ io.github.jpush example-for-spring - 5.0.6 + 5.0.7 8 @@ -26,7 +26,7 @@ io.github.jpush jiguang-sdk - 5.0.6 + 5.0.7 diff --git a/example-for-spring/src/test/java/cn/jiguang/app/api/PushApiTest.java b/example-for-spring/src/test/java/cn/jiguang/app/api/PushApiTest.java index 14deaa2..68ce32d 100644 --- a/example-for-spring/src/test/java/cn/jiguang/app/api/PushApiTest.java +++ b/example-for-spring/src/test/java/cn/jiguang/app/api/PushApiTest.java @@ -63,6 +63,15 @@ public void send() { // 或者发送所有平台 // param.setPlatform(ApiConstants.Platform.ALL); + // Android厂商 + // param.setThirdNotificationMessage(); + + // 短信补充 + // param.setSmsMessage(); + + // 回调 + // param.setCallback(); + // 发送 PushSendResult result = pushApi.send(param); log.info("result:{}", result); diff --git a/example-for-spring/target/classes/application.yml b/example-for-spring/target/classes/application.yml new file mode 100644 index 0000000..2b949cf --- /dev/null +++ b/example-for-spring/target/classes/application.yml @@ -0,0 +1,20 @@ +spring: + application: + name: jiguang-sdk + +server: + port: 9876 + +logging: + level: + root: debug + +jiguang: + api: + # 此为演示数据,请替换成真实数据 + app-key: a266cd5c8544ba09b23733e1 + master-secret: bcf3b3327000abce4764f862 + dev-key: c2dc75e97486529205528b23 + dev-secret: d219e2f001df2fe4f08b6754 + + diff --git a/jiguang-sdk/pom.xml b/jiguang-sdk/pom.xml index f8662dd..e2232e7 100644 --- a/jiguang-sdk/pom.xml +++ b/jiguang-sdk/pom.xml @@ -7,13 +7,13 @@ io.github.jpush jiguang-sdk-java - 5.0.6 + 5.0.7 ../pom.xml io.github.jpush jiguang-sdk - 5.0.6 + 5.0.7 jar diff --git a/jiguang-sdk/src/main/java/cn/jiguang/sdk/api/PushApi.java b/jiguang-sdk/src/main/java/cn/jiguang/sdk/api/PushApi.java index 963aa41..c97f71d 100644 --- a/jiguang-sdk/src/main/java/cn/jiguang/sdk/api/PushApi.java +++ b/jiguang-sdk/src/main/java/cn/jiguang/sdk/api/PushApi.java @@ -100,6 +100,24 @@ public ImageFileUpdateResult updateImageFile(@NonNull String mediaId, @NonNull I return pushClient.updateImageFile(mediaId, param); } + // ********************* 如果遇到此api没有及时补充字段的情况,可以自行构建json,调用下面的接口 ********************* + + public PushSendResult send(Object param) { + return pushClient.send(param); + } + + public SchedulePushSendResult scheduleSend(Object param) { + return pushClient.scheduleSend(param); + } + + public PushSendResult validateSend(Object param) { + return pushClient.validateSend(param); + } + + public PushSendResult sendByFile(Object param) { + return pushClient.sendByFile(param); + } + public static class Builder { private String host = "https://api.jpush.cn"; diff --git a/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/PushSendParam.java b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/PushSendParam.java index b501b15..5eb504c 100644 --- a/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/PushSendParam.java +++ b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/PushSendParam.java @@ -1,10 +1,13 @@ package cn.jiguang.sdk.bean.push; import cn.jiguang.sdk.bean.push.audience.Audience; +import cn.jiguang.sdk.bean.push.callback.Callback; import cn.jiguang.sdk.bean.push.message.custom.CustomMessage; import cn.jiguang.sdk.bean.push.message.inapp.InAppMessage; import cn.jiguang.sdk.bean.push.message.liveactivity.LiveActivityMessage; import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage; +import cn.jiguang.sdk.bean.push.message.notification.ThirdNotificationMessage; +import cn.jiguang.sdk.bean.push.message.sms.SmsMessage; import cn.jiguang.sdk.bean.push.options.Options; import cn.jiguang.sdk.enums.platform.Platform; import com.fasterxml.jackson.annotation.JsonInclude; @@ -54,4 +57,16 @@ public class PushSendParam { @JsonInclude(JsonInclude.Include.NON_NULL) private InAppMessage inApp; + @JsonProperty("notification_3rd") + @JsonInclude(JsonInclude.Include.NON_NULL) + private ThirdNotificationMessage thirdNotificationMessage; + + @JsonProperty("sms_message") + @JsonInclude(JsonInclude.Include.NON_NULL) + private SmsMessage smsMessage; + + @JsonProperty("callback") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Callback callback; + } diff --git a/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/callback/Callback.java b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/callback/Callback.java new file mode 100644 index 0000000..7302734 --- /dev/null +++ b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/callback/Callback.java @@ -0,0 +1,29 @@ +package cn.jiguang.sdk.bean.push.callback; + +import cn.jiguang.sdk.enums.callback.CallbackType; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Callback { + + @JsonProperty("url") + private String url; + + /** + * 取值参考:{@link CallbackType} + */ + @JsonProperty("type") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer type; + + @JsonProperty("params") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map params; + +} diff --git a/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/message/notification/ThirdNotificationMessage.java b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/message/notification/ThirdNotificationMessage.java new file mode 100644 index 0000000..ad2db4f --- /dev/null +++ b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/message/notification/ThirdNotificationMessage.java @@ -0,0 +1,64 @@ +package cn.jiguang.sdk.bean.push.message.notification; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ThirdNotificationMessage { + + @JsonProperty("title") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String title; + + @JsonProperty("content") + private String content; + + @JsonProperty("intent") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Intent intent; + + @JsonProperty("uri_activity") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String uriActivity; + + @JsonProperty("uri_action") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String uriAction; + + @JsonProperty("badge_class") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String badgeClass; + + @JsonProperty("badge_add_num") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer badgeAddNumber; + + @JsonProperty("badge_set_num") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer badgeSetNumber; + + @JsonProperty("sound") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String sound; + + @JsonProperty("channel_id") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String channelId; + + @JsonProperty("extras") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map extras; + + @Data + public static class Intent { + @JsonProperty("url") + @JsonInclude(JsonInclude.Include.NON_NULL) + private String url; + } + +} diff --git a/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/message/sms/SmsMessage.java b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/message/sms/SmsMessage.java new file mode 100644 index 0000000..495f71b --- /dev/null +++ b/jiguang-sdk/src/main/java/cn/jiguang/sdk/bean/push/message/sms/SmsMessage.java @@ -0,0 +1,34 @@ +package cn.jiguang.sdk.bean.push.message.sms; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class SmsMessage { + + @JsonProperty("temp_id") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer tempId; + + @JsonProperty("signid") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer signId; + + @JsonProperty("delay_time") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer delayTime; + + @JsonProperty("active_filter") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Boolean activeFilter; + + @JsonProperty("temp_para") + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map tempParams; + +} diff --git a/jiguang-sdk/src/main/java/cn/jiguang/sdk/client/PushClient.java b/jiguang-sdk/src/main/java/cn/jiguang/sdk/client/PushClient.java index 28b3823..451bfba 100644 --- a/jiguang-sdk/src/main/java/cn/jiguang/sdk/client/PushClient.java +++ b/jiguang-sdk/src/main/java/cn/jiguang/sdk/client/PushClient.java @@ -88,4 +88,22 @@ public interface PushClient { @Headers("Content-Type: multipart/form-data") ImageFileUpdateResult updateImageFile(@Param("media_id") String mediaId, ImageFileUpdateParam param); + // ********************* 如果遇到此api没有及时补充字段的情况,可以自行构建json,调用下面的接口 ********************* + + @RequestLine("POST /v3/push") + @Headers("Content-Type: application/json; charset=utf-8") + PushSendResult send(Object param); + + @RequestLine("POST /v3/schedules") + @Headers("Content-Type: application/json; charset=utf-8") + SchedulePushSendResult scheduleSend(Object param); + + @RequestLine("POST /v3/push/validate") + @Headers("Content-Type: application/json; charset=utf-8") + PushSendResult validateSend(Object param); + + @RequestLine("POST /v3/push/file") + @Headers("Content-Type: application/json; charset=utf-8") + PushSendResult sendByFile(Object param); + } diff --git a/jiguang-sdk/src/main/java/cn/jiguang/sdk/enums/callback/CallbackType.java b/jiguang-sdk/src/main/java/cn/jiguang/sdk/enums/callback/CallbackType.java new file mode 100644 index 0000000..b7c7c60 --- /dev/null +++ b/jiguang-sdk/src/main/java/cn/jiguang/sdk/enums/callback/CallbackType.java @@ -0,0 +1,22 @@ +package cn.jiguang.sdk.enums.callback; + +public enum CallbackType { + + RECEIVED(0b1, "送达回执,值为1"), + CLICKED(0b10, "点击回执,值为2"), + RECEIVED_AND_CLICKED(0b11, "送达和点击回执,值为3"), + PUSH(0b1000, "推送成功回执,值为8"), + PUSH_AND_RECEIVED(0b1001, "推送成功和送达回执,值为9"), + PUSH_AND_CLICKED(0b1010, "推送成功和点击回执,值为10"), + PUSH_AND_RECEIVED_AND_CLICKED(0b1011, "推送成功和送达和点击回执,值为11"), + ; + + private int value; + private String description; + + CallbackType(int value, String description) { + this.value = value; + this.description = description; + } + +} diff --git a/pom.xml b/pom.xml index c8e9446..c24d6d8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.jpush jiguang-sdk-java - 5.0.6 + 5.0.7 pom Jiguang SDK For Rest Api