Skip to content

Commit

Permalink
update version to 5.1.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
wicked-tc130 committed Nov 5, 2024
1 parent 8003193 commit 60f8764
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 21 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
## 1. 集成
引入sdk包
```xml
<!--以5.1.8版本为例-->
<!--以5.1.9版本为例-->
<dependencies>
<!-- jiguang-sdk -->
<dependency>
<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk</artifactId>
<version>5.1.8</version>
<version>5.1.9</version>
</dependency>
</dependencies>
```
Expand Down Expand Up @@ -70,13 +70,16 @@
.setGroupMasterSecret(groupMasterSecret)
.setLoggerLevel(Logger.Level.FULL)
.build();
// 设置client,更多okhttp配置请参考:https://square.github.io/okhttp/5.x/okhttp/okhttp3/-ok-http-client/-builder/index.html

// 设置client
okhttp3.OkHttpClient okHttpClient = new okhttp3.OkHttpClient().newBuilder()
.connectTimeout(5, TimeUnit.SECONDS) // 设置连接超时
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy_host", proxy_port))) // set proxy
.connectTimeout(5, TimeUnit.SECONDS) // set connect timeout
.build();
OkHttpClient client =new OkHttpClient(okHttpClient);

PushApi pushApi = new PushApi.Builder()
.setClient(new OkHttpClient(okHttpClient))
.setClient(new OkHttpClient(client))
.setAppKey(appKey)
.setMasterSecret(masterSecret)
.build();
Expand Down
4 changes: 2 additions & 2 deletions example-for-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>io.github.jpush</groupId>
<artifactId>example-for-spring</artifactId>
<version>5.1.8</version>
<version>5.1.9</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand All @@ -26,7 +26,7 @@
<dependency>
<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk</artifactId>
<version>5.1.8</version>
<version>5.1.9</version>
</dependency>
<!-- lombok -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public class JiguangApiConfig {
@Bean("okHttpClient")
public OkHttpClient okHttpClient() {
okhttp3.OkHttpClient okHttpClient = new okhttp3.OkHttpClient().newBuilder()
// .proxy() // 设置代理,如果有需要
// .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy_host", proxy_port))) // 设置代理,如果有需要
.connectTimeout(5, TimeUnit.SECONDS) // 设置连接超时
.build();
OkHttpClient okHttpClient1 = new OkHttpClient(okHttpClient);
log.info("okHttpClient1:{}", okHttpClient1);
return okHttpClient1;
OkHttpClient client = new OkHttpClient(okHttpClient);
log.info("okHttpClient:{}", client);
return client;
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,10 @@ public void deleteTag() {
deviceApi.deleteTag(tag);
}

@Test
public void getDeviceStatus() {
DeviceStatusGetResult result = deviceApi.getDeviceStatus(Arrays.asList("18171adc023d94a7b6e", "18171adc023d94a7b6e"));
log.info("result:{}", result);
}

}
4 changes: 2 additions & 2 deletions jiguang-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk-java</artifactId>
<version>5.1.8</version>
<version>5.1.9</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk</artifactId>
<version>5.1.8</version>
<version>5.1.9</version>
<packaging>jar</packaging>

<properties>
Expand Down
6 changes: 4 additions & 2 deletions jiguang-sdk/src/main/java/cn/jiguang/sdk/api/DeviceApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import feign.slf4j.Slf4jLogger;
import lombok.NonNull;

import java.util.List;

public class DeviceApi {

private final DeviceClient deviceClient;
Expand Down Expand Up @@ -70,8 +72,8 @@ public void deleteTag(@NonNull String tag, Platform platform) {
deviceClient.deleteTag(tag, platform);
}

public DeviceStatusGetResult getDeviceStatus() {
return deviceClient.getDeviceStatus();
public DeviceStatusGetResult getDeviceStatus(List<String> registrationIds) {
return deviceClient.getDeviceStatus(registrationIds);
}

public static class Builder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package cn.jiguang.sdk.bean.device;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;

@Data
public class DeviceStatusGetParam {

@JsonProperty("registration_ids")
List<String> registrationIds;

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
package cn.jiguang.sdk.bean.device;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@Data
public class DeviceStatusGetResult {

@JsonProperty("registration_ids")
List<String> registrationIds;
@JsonInclude(JsonInclude.Include.NON_NULL)
private Map<String, DeviceStatus> results = new HashMap<>();

@JsonAnySetter
public void handleUnknown(String registrationId, DeviceStatus deviceStatus) {
results.put(registrationId, deviceStatus);
}

@Data
public static class DeviceStatus {

@JsonProperty("online")
private Boolean online;

@JsonProperty("last_online_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime lastOnlineTime;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import feign.Param;
import feign.RequestLine;

import java.util.List;

/**
* (<a href="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device">REST API - Device</a>)
*/
Expand Down Expand Up @@ -49,6 +51,6 @@ public interface DeviceClient {

@RequestLine("POST /v3/devices/status")
@Headers("Content-Type: application/json; charset=utf-8")
DeviceStatusGetResult getDeviceStatus();
DeviceStatusGetResult getDeviceStatus(@Param("registration_ids") List<String> registrationIds);

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk-java</artifactId>
<version>5.1.8</version>
<version>5.1.9</version>
<packaging>pom</packaging>

<name>Jiguang SDK For Rest Api</name>
Expand Down

0 comments on commit 60f8764

Please sign in to comment.