views:

1075

answers:

3

We are testing an application that has APNS and have noticed that sometimes the APNS service for the sandbox environment stops "pushing". The message is successfully received by the apple server, no errors. There are no incoming messages from the feedback service either (we have successfully received feedback on other things). Our codebase for this feature has not changed in a while and has been working rock solid.

My question is, does Apple have some kind of ping that we can send to let us know that the sandbox APNS is alive and working?

Thanks.

+1  A: 

AFAIK, the only way to tell if the service is not working is if your socket connection has issues.

In testing I did find that my deviceId was incorrect at one point and was preventing me from receiving the messages.

Also, not all message delivery is guaranteed, I believe that only the last one sent is guaranteed. Are you receiving any messages from the batch?

The last question would be the type of device that you are testing with, iPod Touches don't get a push the same way that the iPhone does.

If everything on your side checks out maybe you should file a bug report/feature request with apple. Apple Bug Reporter From the apple dev forums it seems like this is a much requested feature.

jessecurry
A: 

Hi Jessecurry

i tried the following code (PHP)

$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apple_push_notification_production.pem';

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
if($apns)
{
 echo "Connection Established<br/>";
 $deviceToken = '**********';//masked

 $body = array();
 $body['aps'] = array(’alert’ => "test message");
 //$body['aps']['badge'] = 1;

 $payload = json_encode($body);


 $apnsMessage = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
 print "sending message :" . $apnsMessage . "<br/>";
 print "sending payload :" . $payload . "<br/>";
 //fwrite($apns, $apnsMessage);

}
else
{ 
 echo "Connection Failed";

 echo $errorString;
 echo $error;
}
socket_close($apns);
fclose($apns);

reply is Connection Established sending message :�� d^÷Îå0ZCd%1ÄuwOOYš'ÊÈ}ârðm¾Í�,{"aps":{"\u2019alert\u2019":"test message"}} sending payload :{"aps":{"\u2019alert\u2019":"test message"}}

But am not able to get the notification

any help?

Kamal Challa
@Kamal:try to uncommon //fwrite($apns, $apnsMessage);then you should get your notification.
Michael Z
A: 

i did the same thing, of course using the fwrite as well. but still the notification was not received on the device. i have tried it on ipod, iphone and ipad - nothing worked.

should i install an ssl certificate (for example issued by GoDaddy)?

what else can be wrong and causing it not to function properly?

yehuda
i got the notifications to work. as it turns out, its just a matter of time, it takes a while (few hours) till the apns starts working normaly for the new account...
yehuda