How to write APNS FeedBack Service using java? - java

I am working on sending Push Notifications to an Apple device using Java. For this i am using JavaPNS-2.1.1 library. I have successfully sent push notifications to an apple device. But when i call APNS FeedBack Service it doesnt return anything.
To test the APNS Feedback Service, i deleted the app first from device then sent few notifications to that device. While sending push notifications i called the FeedBack Service every time i sent push notification. But each time it doesnt return anything. The piece of code for FeedBack Service as below,
List<Device> devices = new Vector<Device>();
FeedbackServiceManager feedbackManager = new FeedbackServiceManager();
feedbackManager.setProxy(host,port);
AppleFeedbackServer server = new AppleFeedbackServerBasicImpl(keystore, password, false);
devices.addAll(feedbackManager.getDevices(server));
return devices;
Can anyone help me on where am i getting it wrong? On few Questions here in StackOverflow, i read it works in SandBox environment only, is it true? As i am also working on SandBox here.
What is the exact response does the Feedback Service provides? Will it give me all notifications failed? Or only the device token to which it doesnt delivered the notification? Suppose i sent 3 notifications to only one device, then will it give me all 3 instances of failure or device token of that device with timestamp of last failure?
When should i call the FeedBack Service? Means exactly after how much time i call it when APNS fails to deliver push notifications?

My experience with the sandbox-feedback service is that it only works if you have two different sandbox-push enabled apps on your device. When you uninstall one of them, you'll get something on the feedback service saying the token isn't valid anymore. This was several years ago when I tested it, so I don't know if it still applies.

Related

how to find failed notifications in IOS APNS calls when device in airplane mode

If sender is sending apns notifications to user successfully and suddenly user sets device to air plane mode or do not disturb mode then how does the sender know if the device has got the notification or not.
Will Apns notify of success or failure to the sender.
----Update to above question below,
is there a way for IOS app to tell the sending java client about the notifications received, without the user's action of launching the app or clicking one the notification.
For e.g. user might be busy and the device may be idle. In such case if a notification arrives, is there a way or API/Method in IOS to send acknowledgement to the sender, that notification with 'someID' is reviced in notification tray.
Reason being, if someOne wants to charge for notifications sent to a device. if user does not recieve it than it may cause problems.
You need to understand the concept of APNS properly. Have a look at the docs to understand it better :) Though, lemme add some key info here to help you :)
There are few wrong assumptions you have about APNS :)
Mistake 1
"If sender is sending apns notifications to user successfully"
I believe by that statement, you mean user using an app sends a APNS to other user using APNS :)
Sorry :) iOS client applications dont directly talk with APNS to send push notifications :) Request to send a push notification might generate at iOS client app (like user types a text and clicks on send) App wont directly make a call to APNS and handover the payload to it :) There is another important entity playing a very important role in background that is your App Server
What happens when I send a text to other user using APNS??
Your application should gather user text and send it to your Application server :) Your Application server then establishes a two way hand shake with APNS :) Once successful it creates the payload in perticular format :) gets the device ID's to which it has to send the data and sends it to APNS finally APNS delivers it to client apps :)
Mistake 2
Will Apns notify of success or failure to the sender.
Apple documentations clearly says APNS is a best effort service :) Which means APNS will not take any guarantee of delivering every single request sent to it :) and does not provide any feedback regarding the successful delivery of packages at client end :)
All the requests that your Application server sends to APNS gets queued and gets delivered when APNS is free to process them :) If request-1 is yet to be processed and request-2 comes from your application server to APNS request-1 will be discarded and request-2 will be processed :)
How to deal with this kind of situations then ?
Once receiving the message your receiver iOS app should talk with your application server and inform that it has received the message/package :)
Assume user 1 sends 2 message :) lets say message1 and message 2 :) now your application server sends message1 to APNS hoping that it will deliver the message :) If APNS sends it to user 2, user 2's app should talk with your app server and say hey I got message 1 :) Now when user 1 sends message 2 your application server knows that no messages are pending to send to user 2 :)
If user 1 sends message 3 and user 2 does not receive anything from APNS when user 1 again sends message 4 and user 2 informs that he has recieved message 4 your application server should be able to identify that it has not recieved the feed back for messge 3 so it should re-send it again :)
There are 100 other ways to keep your Client and server in sync :)
TIP
If you are developing chat app depending on APNS is not feasible solution :) Hope I guided you atleast with the concept :) Happy coding all the best

How to handle deleted app device token in Pushwoosh?

I am using Pushwoosh for sending notifications to Android and iOS apps from Java Webservices. I found it very easy to use.
I have successfully implemented it. I am using createMessage method with multiple device tokens for sending notifications.
I have used it for many times, and was getting proper response. But after some time I'm getting some device tokens in UnknownDevices key in a response. It is because some devices have deleted the app.
So is there any way that I can handle this situation that not sending notifications to devices which have deleted the app? How can I know that device has deleted the app?
Does Pushwoosh blocks account if I keep sending notifications to devices which has deleted the app?
Thanks
There are two ways of handling this:
Send pushes via Tags feature, where you set Tags on the device with the setTags method, not with push tokens. We will remove invalid/expired tokens for you.
You can use getUnregisteredDevices method, which is currently not documented publicly, but the Support team can provide details. the only disadvantage of this method is that it does not return iOS tokens handled by Apple feedback Service.

What about ios push notification disabled for my app?

I'm sending push notifications on devices in Java with Javapns.
When a user uninstalled my app and I send a push to him, I'll find this user in the feedback service, that's ok.
But how it works if the user disabled my app notifications ? How can I know it on server side ?
The app can know it (with UIRemoteNotificationType) and warn the server with a get/post but is there a way to know it on the server ?
The doc isn't clear enough about push notifications sent and user deviced push notifications disabled
You can not. Except for the feedback that you described, you will know nothing. Even if the user installed your app and enabled notifications, it may never get the notification and you won't know about this.

Regarding automatic Push Notification

I am using the Google-GCM service for pushing notifications to a mobile device & building this application in Java EE.
I'm perfectly able to push notifications to the mobile device. And from the client-end (mobile) I'm able to receive input(string).
Henceforth my conceptual question starts: When I'm receiving input from a mobile (let's say: "Hello, Server"), I'm trying to build an automated process on the server-side and in reply it will push a notification (let's say: "Hi client, I'm fine; How are you?") automatically.
I want to grab some idea to push the notification automatically whenever the mobile device is registered. How do I do it?
All realistic implementations of GCM include a stage where an app receives a RegID, and communicates the RegID back to the server, typically via an HTTP service, typically along with some other business specific data. The server would store the RegID, associating it with other data, and later use it to send messages.
Have you implemented automated the delivery of the GCM registration ID to the server yet? If so, in the same piece of code, you might as well push a notification back. If not, do put together some. Server-side implementation would depend on your server's platform, naturally.

Receive email notifications in android app

Im trying to make a simple app (just for learning sake) that will be able to send and receive emails from my own server. I don't have a problem sending emails from my app, my problem is:
How do you receive push notifications from the email server
Have the app check inbox, refresh the inbox list
I have tried searching for this, but have found nothing.
Thanks for your help
C2DM does push notifications, depending on your server. Search stackoverflow for it.
The app can check the inbox with whatever API is available to get the server's status. Even HTTP is possible.
The SampleSyncAdapter sample app is an example of using a sync adapter to regularly synchronize data between the server and the device, but you can use the same idea for download-only.

Categories

Resources