Notnoop/java-apns Github:https://github.com/notnoop/java-apns Introduction
Java-apns is a Java client that serves the APNs service, which is designed to provide a highly scalable, simple, modular interface to the Apple server.
These interfaces require very little code to do most of the cases, and you can also reconfigure the Java-apns library with your own network link library or JSON library.
Links:installation Javadocs changelog Details: easy-to-use, high-performance APNs API support for Apple Feedback Service support enhanced Apple Push Notification support MDM and News Tand Notification Easy to read Apple certificates easy to expand & reuse easy integration in the framework customize the push load support pooling link to the wrong heavy connection Sample Code
To send a notification, your can do it in two steps:
Establish a connection
Apnsservice service =
apns.newservice ()
. Withcert ("/path/to/certificate.p12", "Mycertpassword")
. Withsandboxdestination ()
. build ();
Create & Send messages
String payload = Apns.newpayload (). Alertbody ("Can ' t be simpler than this!"). Build ();
String token = "FEDFBCFB ...";
Service.push (token, payload);
Get inactive list of devices through feedback service
map<string, date> inactivedevices = Service.getinactivedevices ();
For (String DeviceToken:inactiveDevices.keySet ()) {
Date inactiveasof = Inactivedevices.get (Devicetoken);
...
}
Custom Send Content
You can send custom messages that support custom fields
String payload = Apns.newpayload ()
. Badge (3)
. CustomField ("Secret", "What do You");
. Localizedkey ("Game_play_request_format")
. Localizedarguments ("Jenna", "Frank").
Actionkey ("Play"). Build ();
Service.push (token, payload);
Enhanced notification Push Format
String payload = Apns.newpayload ()
. Badge (3)
. CustomField ("Secret", "What do You");
. Localizedkey ("Game_play_request_format")
. Localizedarguments ("Jenna", "Frank")
. Actionkey ("Play")-build ();
Enhancedapnsnotification notification = new Enhancedapnsnotification (enhancedapnsnotification.increment_id ()/* Next ID */,
new Date (). GetTime () + * * Expire in one hour/*,
token/* Device token
);
Service.push (notification);