How do you test the Push Notification feedback service?

前端 未结 3 479
长发绾君心
长发绾君心 2021-02-04 09:56

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?

3条回答
  •  眼角桃花
    2021-02-04 10:44

    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!

提交回复
热议问题