How would you test the APNS feedback service in the sandbox? Or in other words, how do you force a device to be in the feedback?
I think that from the initial round of question "Yes bu how do you get something to show up there? " actually came from the fact that, his tests were not returning any device, i.e., even though he may have had notifications successfully sent to the iPhone/iPad, whenever he queries the FB server, nothing came back, precisely because the app was never removed from the device, therefore the server is just as happy to keep answering "0 devices found" (for example) because no device failed to receive notifications.
So, when the app is removed from the device, only then, the notification server will provide a feedback, i.e., it will finally answer with the list of devices that removed the app.
The idea of the local server is pretty good too.
-Alex
Here is a nasty side effect on Apple's suggestion to keep at least one push enable app. Here's my suggestion to the document posted on the thread:
On the "Issues with the feedback server", it's interesting to note two scenarios: 1) the app is deployed to a real device, on a production mode; 2) the app is deployed to a development device, to the sandbox;
In the 1) the hint to leave one last app (I expect it to be) correct and should work as described; no issues here.
On the 2), one has to make sure the last app is also a development app. Or in other words, to make things simpler, have a second "sandbox app" that is only there to do press the "last man switch".
The issue I'm having is that once I remove my development app, nothing happens on the sandbox feedback server, even though there are other push-enabled apps on the device, however they are all production apps, therefore, they would "report" (if you can say so) to the production feedback server.
The second copy of your app, (a sandbox app) is what we want to have, so it can keep that persistent connection to the sandbox server... then when you remove your "app under test" your sandbox app will hopefully, report to the sandbox and you can do your actual test.
Hoping this is correct ... will test tonite.
If you delete your app from a device, all you have to do is attempt send a single notification to that device and the next time you connect to the feedback server it will return that device. It will then not return the device again until you try to send another notification to that device.
Also, if you send multiple notifications to a device between connections to the feedback server, the device will be returned for every notification that was dennied.
I realize an answer has been accepted for this but in order to do first round of testing without having to constantly install & remove my application from my phone/ipod I created a VERY simple ruby script to act as the feedback server. I configured my ruby APNS class to connect to this server instead (localhost:2196) and read from it. I did NOT init an SSL connection so I just used the base socket instead. Below is the script I used to 'host' the server.
#!/usr/bin/env ruby
require 'socket'
puts 'Opening server'
server = TCPServer.open(2196)
loop {
puts 'Waiting for connection'
client = server.accept
puts 'Connected preparing data'
data = [1, 2, 3, 4, 0, 32, ['d41c3767074f541814c2207b78f72e538569cb39eae60a8c4a8677549819e174']]
puts 'Data for delivery: ' + data.inspect
begin
data[6] = data[6].pack('H*')
data = data.pack('c6a*')
loop {
puts 'Writing Data'
client.write data
puts 'Sleeping for 5 seconds'
sleep 5
}
rescue
end
puts 'Done writing, closing'
client.close
}
This script will listen and when it receives a connection every 5 seconds write a packet to the socket. If the connecting socket closes (for example you kill your feedback process) then this script resets and waits for a new connection.
Remember, do not use the SSL connection stuff just a standard ruby socket. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With