Apple Push Notification Service (APNS) Development guidelines

Source: Internet
Author: User

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.