Apple Push notifications server - Feedback always returns zero tuples - iphone

I am developing an iPhone App that uses Apple Push Notifications. On the iPhone side everything is fine, on the server side I have a problem. Notifications are sent correctly however when I try to query the feedback service to obtain a list of devices from which the App has been uninstalled, I always get zero results. I know that I should obtain one result as the App has been uninstalled from one of my test devices. After 24 hours and more I still have no results from the feedback service..
Any ideas? Does anybody know how long it takes for the feedback service to recognize that my App has been uninstalled from my test device? Could it be due to the sandbox environment?

I have just had exactly the same problem:
int bytesReceived = 0;
byte[] feedbackPacket = new byte[38]; // Each feedback should always be 38 bytes long
bytesReceived = stream.Read(feedbackPacket, 0, feedbackPacket.Length);
while(bytesReceived > 0)
{
ProcessFeedback(feedbackPacket);
Array.Clear(feedbackPacket, 0, feedbackPacket.Length);
bytesReceived = stream.Read(feedbackPacket, 0, feedbackPacket.Length);
}
On the sandbox, the above always returned 0 bytesReceived. I ran this on the live host, sending a single notification to a device, removing the app and sending a second. The feedback service work within a second of sending the second request.
One thing I haven't found is how often to call the feedback service however. I'll calling every 10 mins at the moment.

I had the same problem with sandbox environment. Zero tuples return by the feedback service.
I switched to production environment to test my code and everything worked fine. As soon as I uninstalled the app from the device and sent a pair of push notification, this device appeared in the feedback list.

Although I can't say definetly it does not work in sandbox environment, i'm pretty sure about it. In production environment, after uninstalling my application, I sent a few (i guess 3) push notifications. Then feedback service returned results other than zero tuples. (about in ten minutes)
It is not related with this case, but also in order to get notifications and also get feedback results, your network should allow ports that APNS use.

As Zakum said in a comment, the device will not get added to the list if you delete the last push-enabled app.
(And make sure to give it enough time - maybe 10 to 20 minutes.)
From Apple Documentation:
If you remove your app from your device or computer and then send a push notification to it, you would expect to have the device token rejected, and the invalidated device token should appear on the feedback service. However, if this was the last push-enabled app on the device or computer, it will not show up in the feedback service. This is because deleting the last app tears down the persistent connection to the push service before the notice of the deletion can be sent.
You can work around this by leaving at least one push-enabled app on the device or computer in order to keep the persistent connection up. To keep the persistent connection to the production environment up, just install any free push-enabled app from the App Store and you should then be able to delete your app and see it appear in the feedback service.
Recall that each push environment has its own persistent connection. So to keep the persistent connection to the sandbox environment up, install another development push-enabled app.

Related

Is a server required for push notifications?

Just to start I, I want to say I have read the this tutorial: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
After reading it, had a few questions about push notifications... my main questions is, is a server required.
I have made an app that has informational content for my business... however every week/month or whenever I choose, I want to be able to push a message to all the user who have downloaded my app (every device would receive the same message).
Preferably, the way I would want to create and send the notifications... is through a separate app that I, the developer only has.
Now back to my question, would I need to get a server to do this?
There are a lot of free Push Notification servers - for example QuickBlox
You don't need any server code, QuickBlox already wrote all for you.
Just look at Push Notifications iOS sample - This sample enables you to send notifications and alerts to users at any time through an API or easy-to-use admin panel.
Just download it, move some code from it to your app - and enjoy it.
We use a framework called Parse that let's us send broadcast pushes to all users. You don't need to maintain a server (they do it for you). It's free for under 5 million queries a month.
No you dont need a server, you can simply create your own application that connects to the apple push notification server but you have to ensure you use the required develop/publish certificate for the ssl connection, you can see that on the tutorial you read in the "Making a PEM file" secction. He is connecting directly from his mac to the servers, it fails without the certificate but it doesnt with it.
See here:
As I’ve mentioned a few times before, you need to set up a server that
sends the push notifications to your app. For this first test, we’re
not going to set up a server just yet. Instead, I’ll give you a very
simple PHP script that sets up a connection to APNS and sends a push
notification to a device token that you specify. You can run this
straight from your Mac.
You can make your program set up a connection like that.

Push Notifcation Woes with Titanium & XCode

I am using Titanium 2.0.2 to create an iPhone app which must, amongst other things, be able to receive push notifications. I have done the following
a. Created the AppID in my Apple Developer account
b. Configured the AppID for Push
c. Created a new provisioning profile using the newly created AppID
d. For good measure edited that profile - given that I have heard reports that the first time round it does not pick up the AppID Push info correctly
Armed with all of that I have proceeded to register my app for Push using Ti.Network.registerForPUshNotifications and coded the success, error and callback methods. I have closely followed the example in the Titanium Kitchen Sink demo.
Having done all this I had fully expected one of the following outcomes
Registration succeeds and I get the alert message I have stuck in the Success callback.
Registration fails and I get the alert message in my Error callback
Much to my surprise nothing happens at all - it is like the registerForPushNotifications call goes out into the ether and is well...gone
To be doubly sure I created a simple XCode project following the excellent tutorial at http://maniacdev.com/2011/05/tutorial-ios-push-notification-services-for-beginners/. The app registers with APNS and I trap the assigned remoteDeviceUUID using my iPad and http://itunes.apple.com/us/app/consolelog/id415116252?mt=8. I have then adapted the simplepush.php script from ManicDev and run it off my local WAMP server. It gets through to APNS and deposits my very first PUSH message. But it never arrives on my iPad!
For the sake of completeness I should mention that I am getting a development build onto my iPad with the help of TestFlightApp.
So what am I doing wrong here?
a. Why does Titanium simply not want to do anything in response to RegisterForPushNotifications?
b. Wny does my sample XCode app never get the Push notification?
I would hugely appreciate any help on this one.
A note for anyone running into this post. Beware of testing Push notifications on your iPad behind a WiFi firewall router. Most routers block access to the port used by APNS. I spent way too much time trying to find a "bug" in my code only to discover that there wasn't one. Putting the device in the DMZ on your router might help but is not reliable - at least not with my Sitecom router.
The adhoc builds that Test Flight uses are "Production" in terms of the push notifications not development ones so mostly likely your server needs to be configured with the Production APNS server keys to get it to work.

Offline notifications in iOS

According to the APNS Reference at Apple.com, an iOS device cannot receive notifications while it's offline / not connection to 3G or WiFi or similar. Yesterday I found an application (Pillboxie) that claims to be able to notify users even though they're offline. I quote:
"In order to use reminder technology that doesn't requre a network connection, Pillboxie will only run on devices running iOS 4.0 or later."
and
"No network connection required!"
Both quotes are copied from the App Description in the App Store.
I have not succeeded to find out how this works and whether it is as reliable as APNS. Does anyone know anything about the offline noficiation service mentioned in the quote above?
Pillboxie uses UILocalNotification to do that.
It is totally implemented on the app itself, without the need of a server side notification or even the internet connection.
You will not be able to use that for sending push notification, from a server to the user device, which is the one that requires the internet connection (wi-fi or 3G).
You can read more about it in Apple's Local and Push Notification Programming Guide
I believe they refer to local notifications and not remote notifications.
Loacl notification are stored locally in the user device. And shot by the iOS itself.
From UIlocalnotification reference:
The operating system is responsible for delivering the notification at the proper time; the application does not have to be running for this to happen. Although local notifications are similar to remote notifications in that they are used for displaying alerts, playing sounds, and badging application icons, they are composed and delivered locally and do not require connection with remote servers.
I'm the developer of Pillboxie. Felipe is correct: Pillboxie uses UILocalNotifications to schedule its reminders. I chose local notifications over push for several reasons. There are pros and cons to either kind. I chose UILocalNotification because it made more sense with the serious medical nature of Pillboxie:
LOCAL NOTIFICATIONS
PROS: Don't need to manage your own server to interface with the APNS. Very reliable, always on time; Works for people who don't have a network connection often (iPod Touch and iPad users); Works when traveling overseas; Automatically adjusts to the current wall-clock time in the current system time zone (if you've set a reference time zone in the time zone property in the UILocalNotification).
CONS: Max of 64 notifications per app; Can only repeat in whole units of either 1 minute, 1 hour, 1 day, 1 week, etc. If repeating, can't set a stop date.
There are actually 2 types of notifications.
Push - generated by APNS require internet connection
Local - generated on device by the application
So the app you are reffering to might be using local notifications. Check docs for more

Inconsistency in receiving push notification

I found some weird behavior in push notification. My iPod app receives push notifications till last week with no issues. Then I found that my app is not receiving push notifications, and I changed the certificates and it worked fine, and after 2 days its not working. And I repeated the same process and same kinda problem. I was wondering why this happens?
NOTE I am using my own java based server to send push notification. I am sure that my certification are not expired. At the time of this problem the badge id is also not visible with my application icon.??
Thanks in advance.
Ensure a few things
You are using the correct combination of production or dev pem and the APNS or sandbox server URL
Check the Feedback services to ensure whether you are getting any errors
I faced similar issues with my 3GS running OS 4.1 last week. It started working after I restarted my device. Try doing that and see if it works.
Please make sure to update the device token in the database of you provider. I guess some updates in your iOS/certificates may changed your device token. Just make a test around that.
Try lostInTransit's solution and also check for your internet connectivity. I also faced this issue with my iPod sometimes the push notifications not come in my iPod. Try this -
Install facebook iPhone app on your device.
Send a test push notification from your server.
If the notification does not come then do something with facebook which should generate the notification.
If the notification from facebook does not come it means its related to your net connectivity.And your code is perfect.
Sometimes I see that when my iPod is on DHCP it does not receive the notification but when I assign it a static network (dedicated IP) it works fine.

Apple Push Notification Service - notification messages aren't sent to iphone device

I constructed provider code with using C# and it was able to send notification messages to iphone devices successfully. But since yesterday, it hasn't worked. Also it seems to connect APNS successfully and send notification message. Unfortunately, no notification message is received by iphone device. I controlled internet connection and device token of iphone device. What else can I do? Thanks in advance...
I dont have enough rep to comment on the question so typing out answer - Please add more details and I will edit my answer.
Is this in a developer / testing environment and are you using an ad hoc profile to install the application on the iphone devices?
Did you check if the device token has changed and that you are using the new/ correct token in the C# code?
Do provide more details of your problem.
Crazywood, I don't have a solid answer for you but I can tell you I'm in the same boat as you.
There are times when all my notifications go through and times when none of them seem to.
One guess is that not all notifications are sent. According to the docs, in production remote notifications are not guaranteed to be received by the client. My guess is that this is also the case for the sandbox.
-------- EDIT ------
I went through the trouble shooting list (http://developer.apple.com/library/ios/#technotes/tn2010/tn2265.html) and came across this:
The device may have lost its persistent connection to the push service and can't reconnect. Try quitting the app and relaunching it to see if registration completes the next time. (On iOS 4 and later on devices that support multitasking, you will need to force quit the app from the recents list.) If the registration does not complete, iOS has been unable to re-establish the persistent connection. You can troubleshoot this as described in the previous two sections.
I restarted the app and it made no difference. Then I rebooted my phone. That seemed to do the trick.