Skip to content

Commit 4a243bb

Browse files
authored
Merge pull request #171 from yutaipu/master
支持文件推送、支持消息撤回、自动化
2 parents 2532940 + ee6f820 commit 4a243bb

File tree

12 files changed

+291
-140
lines changed

12 files changed

+291
-140
lines changed

.classpath

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/maven.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish package to the Maven Central Repository
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up JDK 1.8
13+
uses: actions/setup-java@v1
14+
with:
15+
java-version: 1.8
16+
17+
- name: Build with Maven
18+
run: mvn -B clean package -Dmaven.test.skip
19+
20+
- name: Set up Apache Maven Central
21+
uses: actions/setup-java@v1
22+
with: # running setup-java again overwrites the settings.xml
23+
java-version: 1.8
24+
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
25+
server-username: MAVEN_USERNAME # env variable for username in deploy
26+
server-password: MAVEN_PASSWORD # env variable for token in deploy
27+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
28+
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
29+
30+
- name: Publish to Apache Maven Central
31+
run: mvn deploy -Dmaven.test.skip
32+
env:
33+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
34+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
35+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ test-output/
1414
*.iml
1515

1616
*.releaseBackup
17-
release.properties
18-
17+
release.properties

.project

Lines changed: 0 additions & 29 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
对应的 REST API 文档:[REST API - Push](https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/), [REST API - Report](https://docs.jiguang.cn/jpush/server/push/rest_api_v3_report/).
1010

11-
本开发包 Javadoc:[API Docs](http://jpush.github.io/jpush-api-java-client/apidocs/)
12-
1311
版本更新:[Release页面](https://github.com/jpush/jpush-api-java-client/releases)。下载更新请到这里。
1412

1513
> 非常欢迎各位开发者提交代码,贡献一份力量,review过有效的代码将会合入本项目。
@@ -24,7 +22,7 @@
2422
<dependency>
2523
<groupId>cn.jpush.api</groupId>
2624
<artifactId>jpush-client</artifactId>
27-
<version>3.4.6</version>
25+
<version>3.4.7</version>
2826
</dependency>
2927
```
3028
### jar 包方式

pom.xml

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>cn.jpush.api</groupId>
55
<artifactId>jpush-client</artifactId>
6-
<version>3.4.7-SNAPSHOT</version>
6+
<version>3.4.7</version>
77
<packaging>jar</packaging>
88
<url>https://github.com/jpush/jpush-api-java-client</url>
99
<name>JPush API Java Client</name>
@@ -229,9 +229,83 @@
229229
</dependency>
230230
</dependencies>
231231
</plugin>
232+
233+
<!-- 参考 https://docs.github.com/cn/actions/language-and-framework-guides/publishing-java-packages-with-maven#about-package-configuration -->
234+
<!-- 参考 https://github.com/actions/setup-java -->
235+
<!-- 参考 https://central.sonatype.org/pages/apache-maven.html -->
236+
237+
<!-- Javadoc和源代码附件 -->
238+
<plugin>
239+
<groupId>org.apache.maven.plugins</groupId>
240+
<artifactId>maven-source-plugin</artifactId>
241+
<version>2.2.1</version>
242+
<executions>
243+
<execution>
244+
<id>attach-sources</id>
245+
<goals>
246+
<goal>jar-no-fork</goal>
247+
</goals>
248+
</execution>
249+
</executions>
250+
</plugin>
251+
<plugin>
252+
<groupId>org.apache.maven.plugins</groupId>
253+
<artifactId>maven-javadoc-plugin</artifactId>
254+
<version>2.9.1</version>
255+
<executions>
256+
<execution>
257+
<id>attach-javadocs</id>
258+
<goals>
259+
<goal>jar</goal>
260+
</goals>
261+
</execution>
262+
</executions>
263+
</plugin>
264+
265+
<!-- GPG签名组件 -->
266+
<plugin>
267+
<groupId>org.apache.maven.plugins</groupId>
268+
<artifactId>maven-gpg-plugin</artifactId>
269+
<version>1.5</version>
270+
<executions>
271+
<execution>
272+
<id>sign-artifacts</id>
273+
<phase>verify</phase>
274+
<goals>
275+
<goal>sign</goal>
276+
</goals>
277+
</execution>
278+
</executions>
279+
</plugin>
280+
281+
<!-- Nexus Staging Maven插件,用于部署和发布 -->
282+
<plugin>
283+
<groupId>org.sonatype.plugins</groupId>
284+
<artifactId>nexus-staging-maven-plugin</artifactId>
285+
<version>1.6.7</version>
286+
<extensions>true</extensions>
287+
<configuration>
288+
<serverId>ossrh</serverId>
289+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
290+
<!-- 手动release -->
291+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
292+
</configuration>
293+
</plugin>
294+
232295
</plugins>
233296
</build>
234297

298+
<distributionManagement>
299+
<snapshotRepository>
300+
<id>ossrh</id>
301+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
302+
</snapshotRepository>
303+
<repository>
304+
<id>ossrh</id>
305+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
306+
</repository>
307+
</distributionManagement>
308+
235309
<reporting>
236310
<plugins>
237311
<plugin>

src/main/java/cn/jpush/api/JPushClient.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ public PushResult sendPush(PushPayload pushPayload) throws APIConnectionExceptio
204204
public PushResult sendPush(String payloadString) throws APIConnectionException, APIRequestException {
205205
return _pushClient.sendPush(payloadString);
206206
}
207+
208+
/**
209+
* Send a file push with PushPayload object.
210+
*
211+
* @param pushPayload payload object of a push.
212+
* @return PushResult The result object of a Push. Can be printed to a JSON.
213+
* @throws APIConnectionException if a remote or network exception occurs.
214+
* @throws APIRequestException if a request exception occurs.
215+
*/
216+
public PushResult sendFilePush(PushPayload pushPayload) throws APIConnectionException, APIRequestException {
217+
return _pushClient.sendFilePush(pushPayload);
218+
}
207219

208220
/**
209221
* Validate a push action, but do NOT send it actually.
@@ -848,6 +860,16 @@ public PushResult sendMessageWithRegistrationID(String title, String msgContent,
848860
return _pushClient.sendPush(payload);
849861
}
850862

863+
/**
864+
* Delete a push by msgId.
865+
* @param msgId The message id
866+
* @return delete result
867+
* @throws APIConnectionException if a remote or network exception occurs.
868+
* @throws APIRequestException if a request exception occurs
869+
*/
870+
public DefaultResult deletePush(String msgId) throws APIConnectionException, APIRequestException {
871+
return _pushClient.deletePush(msgId);
872+
}
851873

852874

853875
// ----------------------- Device
@@ -1233,5 +1255,7 @@ private ScheduleResult createPeriodicalSchedule(String name, String start, Strin
12331255
public void close() {
12341256
_pushClient.close();
12351257
}
1258+
1259+
12361260
}
12371261

0 commit comments

Comments
 (0)