Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:35:13+00:00 2026-06-11T02:35:13+00:00

I am using the Java-APNS framework to send push notifications to iOS devices. It

  • 0

I am using the Java-APNS framework to send push notifications to iOS devices. It works very well (thanks to the developer!) and I am able to send to my devices when everything is set up correctly. I would like, however, to properly handle fail cases. There are some documented APNS error codes that should be received for certain cases:

http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW1

How would I create some of the fail cases? I have my own class that implements ApnsDelegate and construct my ApnsService object with my delegate. I’ve tried passing an invalid token in my call to push as well as an empty string for payload:

service.push("ab", "")

but the messageSent method of my ApnsDelegate still gets called. I would expect this to end up in the messageSendFailed method instead or maybe the connectionClosed but neither gets called. Has anyone tested this stuff and gotten it to work? Here is an example of my class…I’m actually doing this in Scala but figured I would have better luck if I posted Java. When called, this will just print “Message sent to AB”.

public class ApnsSender implements ApnsDelegate {

    public void send(Notification Notification) {
        ApnsService service = getApnsService();

        String payload = getPayload(notification);

        service.push("ab", "");
    }

    private ApnsService getApnsService() { ... }

    private String getPayload(Notification notification) { ... }

    public void messageSent(ApnsNotification message) {
        String token = Utilities.toHexString(message.getDeviceToken());
        System.out.println("Message sent to " + token);
    }

    public void messageSendFailed(ApnsNotification message, Throwable e) {
        System.out.println("Message failed");
    }

    public void messageSent(DeliveryError e, Int messageIdentifier) {
        System.out.println("Message closed with error code " + e.code());
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:35:15+00:00Added an answer on June 11, 2026 at 2:35 am

    As mentioned in my comment, I looked into JavaPNS as an alternative and this is a much better framework to use. It’s also being currently worked on (last commit 2 days ago at time of posting) where as java-apns hasn’t been updated since December of 2011.

    I suggest that use of java-apns be replaced with use of JavaPNS for anyone trying to send push notifications to iOS devices. It reacts to error packets received and passes the results on to the caller in an easy to access fashion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using notnoop APNS Java library to send APNS notifications. Since we have a
Hello I am trying to send a push message to my device using Java.
Using Java sockets, I made a simple server. This works because it sends data
Using Java (.jsp or whatever) is there a way where I can send a
I am using Java Robot class to send keyevents. I tried robot.keyPress() function. But
I have a grails app, and I am using the java-apns 0.1.5 jar! I
Using JAVA framework i want to achieve the following task. hot code(jar) deployment which
Greetings, I am creating a Java based server to create push notifications for Apple's
Using Java IO streams, it is quite often we use objects solely as constructors
Using java If I store windows paths in a h2 database, and then try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.