Git Product home page Git Product logo

java-apns2's Introduction

java-apns2

HTTP/2 Apple Push Notification Service (APNs) push provider for JAVA

Features

  • 使用苹果最新的推送协议(基于HTTP/2)
  • 基于jetty Http2Client
  • 基于线程池,维持到APNs的长连接(断线重连,定时发送心跳帧)
  • 异步推送,保证推送效率

Install

  • 在java9正式推出之前,需要ALPN支持,具体可以看 jetty ALPN.
  • 直接check out本项目到本地(即将支持maven安装)

Example

Apns2Config config = new Apns2Config.Builder()
                .key("keyfile.p12")
                .password("yourPassword")
                .topic("yourTopic")
                .poolSize(2)
                .build();

ApnsHttp2Service service = new ApnsHttp2ServiceImpl(config);

Notification notification = new Notification.Builder()
        .alertBody("hello")
        .alertTitle("titletest")
        .badge(1)
        .build();

service.push("afae802f3bb27e5606c74495453bb4534fc36c5606f663ad4b92afe392e5d7d2", notification, new ResponseListener() {
    @Override
    public void success(String deviceToken, Notification notification) {
        System.out.println(notification.getPayload());
    }

    @Override
    public void failure(String deviceToken, Notification notification, int status, String reason) {
        System.out.println("status:" + status + " reason:" + reason);
    }
});

try {
    Thread.sleep(10000);
} catch (InterruptedException e) {
    e.printStackTrace();
}
service.shutdown();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.