[Best to use] Java APNS open source library apns4j-1.1.1 released

Open source address: https://github.com/teaey/apns4j

[Best to use] Java APNS open source library apns4j-1.1.1 released

  • Improve the ease of use of the API, remove complicated initialization logic, and focus on cn.teaey.apns4j.Apns4j

  • Provides a simple asynchronous service

  • Increase the silent push setting (content-available) for ios7 and above

  • sendAndFlush -> send may have been a mistake to begin with!

  • Reduce the builder mode and better integrate with frameworks such as spring

  • groupId adjustment: cn.teaey.apns4j

<dependency>
    <groupId>cn.teaey.apns4j</groupId>
    <artifactId>apns4j</artifactId>
    <version>1.1.1</version>
</dependency>
//Step 1
ApnsChannelFactory apnsChannelFactory = Apns4j.newChannelFactoryBuilder()
.keyStoreMeta("${path to your keystore}")
.keyStorePwd("${keystore password}")
.build();

//Setp 2
ApnsChannel apnsChannel = apnsChannelFactory.newChannel();

//Step 3 create & init notify payload
ApnsPayload apnsPayload = Apns4j.newPayload()
        .alertTitle("Title")
        .alertBody("Pushed by apns4j")
        .sound("default");

//Step 4 send via channel
apnsChannel.send("${target device token}", apnsPayload);

//Step 5 in the end, apnsChannel can be Recycle and Reuse 
apnsChannel.close();

from iteye

Open source address: https://github.com/teaey/apns4j

Contact the author: 
[email protected] 
github: http://github.com/teaey

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326485012&siteId=291194637