JMessage API Java Client

JPush's officially supported Java client library for accessing JMessage APIs.

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

cn.jpush.api
ArtifactId

ArtifactId

jmessage-client
Last Version

Last Version

1.1.11
Release Date

Release Date

Type

Type

jar
Description

Description

JMessage API Java Client
JPush's officially supported Java client library for accessing JMessage APIs.
Project URL

Project URL

https://github.com/jpush/jmessage-api-java-client
Source Code Management

Source Code Management

https://github.com/jpush/jmessage-api-java-client

Download jmessage-client

How to add to project

<!-- https://jarcasting.com/artifacts/cn.jpush.api/jmessage-client/ -->
<dependency>
    <groupId>cn.jpush.api</groupId>
    <artifactId>jmessage-client</artifactId>
    <version>1.1.11</version>
</dependency>
// https://jarcasting.com/artifacts/cn.jpush.api/jmessage-client/
implementation 'cn.jpush.api:jmessage-client:1.1.11'
// https://jarcasting.com/artifacts/cn.jpush.api/jmessage-client/
implementation ("cn.jpush.api:jmessage-client:1.1.11")
'cn.jpush.api:jmessage-client:jar:1.1.11'
<dependency org="cn.jpush.api" name="jmessage-client" rev="1.1.11">
  <artifact name="jmessage-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.jpush.api', module='jmessage-client', version='1.1.11')
)
libraryDependencies += "cn.jpush.api" % "jmessage-client" % "1.1.11"
[cn.jpush.api/jmessage-client "1.1.11"]

Dependencies

compile (1)

Group / Artifact Type Version
cn.jpush.api : jiguang-common jar 1.1.3

provided (6)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.3
org.slf4j : slf4j-api jar 1.7.7
org.slf4j : slf4j-log4j12 jar 1.7.7
log4j : log4j jar 1.2.17
junit : junit jar 4.11
com.squareup.okhttp : mockwebserver jar 2.0.0

Project Modules

There are no modules declared in this project.

GitHub version

JMessage API Java Library

概述

这是 JMessage REST API 的 Java 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。

对应的 REST API 文档:https://docs.jiguang.cn/jmessage/server/rest_api_im/

版本更新:Release页面。下载更新请到这里。

非常欢迎各位开发者提交代码,贡献一份力量,review过有效的代码将会合入本项目。

安装

maven 方式

将下边的依赖条件放到你项目的 maven pom.xml 文件里。

其中 slf4j 可以与 logback, log4j, commons-logging 等日志框架一起工作,可根据你的需要配置使用。

<dependency>
    <groupId>cn.jpush.api</groupId>
    <artifactId>jmessage-client</artifactId>
    <version>1.1.9</version>
</dependency>
<dependency>
    <groupId>cn.jpush.api</groupId>
    <artifactId>jiguang-common</artifactId>
    <version>1.1.3</version>
</dependency>
<dependency>
	<groupId>com.google.code.gson</groupId>
	<artifactId>gson</artifactId>
	<version>2.3</version>
</dependency>
<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-api</artifactId>
	<version>1.7.7</version>
</dependency>

<!-- For log4j -->
<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-log4j12</artifactId>
	<version>1.7.7</version>
</dependency>
<dependency>
	<groupId>log4j</groupId>
	<artifactId>log4j</artifactId>
	<version>1.2.17</version>
</dependency>

jar 包方式

请到 Release页面下载相应版本的发布包。

依赖包

其中 slf4j 可以与 logback, log4j, commons-logging 等日志框架一起工作,可根据你的需要配置使用。

jiguang-common 的 jar 包下载。请点击

编译源码

如果开发者想基于本项目做一些扩展的开发,或者想了解本项目源码,可以参考此章,否则可略过此章。

导入本项目

  • 可以采用 git clone https://github.com/jpush/jmessage-api-java-client.git jmessage-api-src 命令下载源码
  • 如果不使用git,请到Release页面下载源码包并解压
  • 采用eclipse导入下载的源码工程,推荐采用maven的方式,方便依赖包的管理
  • 假如采用导入普通项目的方式,项目报错,检查Build Path,Libraries
  • 依赖jar包都在libs目录下可以找到,没有加入的请添加到Build Path,Libraries
  • jpush-client jar包可以点击下载
  • 默认采用了log4j做日志框架,开发者可根据自己需求替换logback、commons-logging等日志框架
  • 极个别情况下,如果test目录报错,请手动添加test的依赖jar包mockwebserver-2.0.0.jar、okhttp-2.0.0.jar、okio-1.0.0.jar
  • 开发者需要注意,将本项目的编码格式设置为UTF-8

构建本项目

可以用 Eclipse 类 IDE 导出 jar 包。建议直接使用 maven,执行命令:

maven package

自动化测试

在项目目录下执行命令:

mvn test

使用样例

以下片断来自项目代码里的文件:example / cn.jmessage.api.examples.UserExample

	public static void testGetUserInfo() {
        JMessageClient client = new JMessageClient(appkey, masterSecret);
        try {
            String res = client.getUserInfo("test_user");
            LOG.info(res);
        } catch (APIConnectionException e) {
            LOG.error("Connection error. Should retry later. ", e);
        } catch (APIRequestException e) {
            LOG.error("Error response from JPush server. Should review and fix it. ", e);
            LOG.info("HTTP Status: " + e.getStatus());
            LOG.info("Error Message: " + e.getMessage());
        }
    }

以下片断来自项目代码里的文件:example / cn.jmessage.api.examples.GroupExample

	public static void testCreateGroup() {
        JMessageClient client = new JMessageClient(appkey, masterSecret);
        try {
            String res = client.createGroup("test_user", "test_gname1", "description", "test_user");
            LOG.info(res);
        } catch (APIConnectionException e) {
            LOG.error("Connection error. Should retry later. ", e);
        } catch (APIRequestException e) {
            LOG.error("Error response from JPush server. Should review and fix it. ", e);
            LOG.info("HTTP Status: " + e.getStatus());
            LOG.info("Error Message: " + e.getMessage());
        }
    }

贡献者列表

cn.jpush.api

极光开发者

JiGuang's official open source endpoint. 极光开发者服务官方开源站。包括:极光推送(JPush)、极光IM(JMessage)、极光短信(JSMS)、极光统计(JAnalytics)等相关开源项目。

Versions

Version
1.1.11
1.1.10
1.1.9
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.2
1.0.1
1.0.0
0.1.3
0.1.2
0.1.1
0.1.0