How do you test iphone push notification feedback service
I need a way to test Push notification feedback service. I can send the notifications fine.
I installed the开发者_JAVA技巧 app using XCode to my dev IPod, sent push notifications just fine, the app received them ok.
I uninstalled the app, sent a few push notifications. Then tried the feedback service, but no luck. I do not receive any bytes back from the stream.
Even tried waiting for upto a day. Tried the same on a different iphone, but nothing. I am sure the code is fine, double checked the url and port etc, all fine. Besides using the same settings (apart from url and port) I can send the pushes just fine.
So I am not sure what to do now. I have searched on the web, but could not find anything useful. Someone suggested exactly what i have already tried (send push -> uninstall -> send push -> listen for feedback).
Any ideas? Any way ican make sure that its fine before pushing it live?
Below is the code (C#):
using (TcpClient client = new TcpClient())
{
client.Connect("feedback.sandbox.push.apple.com", 2196);
using (NetworkStream networkStream = client.GetStream())
{
Console.Out.WriteLine("Client Connected");
X509Certificate cert = new X509Certificate(fileLocation, password);
X509CertificateCollection certCollection = new X509CertificateCollection(new X509Certificate[1] { cert });
SslStream ssl = new SslStream(client.GetStream(), true, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
try
{
int bytesRead;
byte[] b = new byte[38];
ssl.AuthenticateAsClient("feedback.sandbox.push.apple.com", certCollection, SslProtocols.Default, false);
do
{
bytesRead = ssl.Read(b, 0, b.Length);
}
while (bytesRead != 0);
ssl.Close();
}
catch (AuthenticationException e)
{
Console.WriteLine("Exception: {0}", e.Message);
return;
}
}
}
There should be at least one push application installed on the device. If you uninstall the application and there are no push apps on the device the device does not connect to push in order to preserve the battery.
See the Apple Documentation: When deleting the last push-enabled application on a device, the Apple servers are not notified of the deletion of the Application, so the device will never appear on the feedback server.
To work-around this, you should create a dummy app that would register for Push Notifications in development mode before removing the App you were testing.
精彩评论