views:

297

answers:

3

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?

A: 

Apple provides a separate push server for sandbox testing.

You'll need a developer push certificate from Apple's developer connection site.

Then you just have to set your delivery host to:

host = 'gateway.sandbox.push.apple.com'
port = 2195

That will let you use your development certificate in sandbox testing.

Matt
Yes bu how do you get something to show up there?
David Beck
get "what" to show up "where"... please be more specific.
Jann
I have push working fine in the sandbox, however I would like to test the FEEDBACK SERVICE. How do I get a device to appear in the feedback service?
David Beck
feedback_host = 'feedback.sandbox.push.apple.com'feedback_port = 2196You should be able to see any feedback you've got for devices using this socket.
Matt
A: 

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.

David Beck
A: 

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!

Matt S