简体   繁体   中英

iOS push notifications feedback service

I can send to my swift 2 app push notifications via PHP. now I would like to have a script for the feedback service.

I found this:

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'xxx.pem');
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);

$fp = stream_socket_client('ssl://feedback.push.apple.com:2196', $error, $errorString, 60, STREAM_CLIENT_CONNECT, $ctx);

if (!$fp) {
 echo "Failed to connect feedback server:".$err.". ".$errstr."<br />";
 exit();
}
else {
 echo "Connection to feedback server OK<br />";
}

 echo "APNS feedback results<br />";
 while ($devcon = fread($fp, 38))
 {
 $arr = unpack("H*", $devcon);
 $rawhex = trim(implode("", $arr));
 $feedbackTime = hexdec(substr($rawhex, 0, 8));
 $feedbackDate = date('Y-m-d H:i', $feedbackTime);
 $feedbackLen = hexdec(substr($rawhex, 8, 4));
 $feedbackDeviceToken = substr($rawhex, 12, 64);
 echo "TIMESTAMP:" . $feedbackDate . "<br />";
 echo "DEVICE ID:" . $feedbackDeviceToken. "<br /><br />";
 }
fclose($fp);

This code shows me that:

Connection to feedback server OK
APNS feedback results

But no result. I sent a few minutes ago and push notification to a token 0. this is an invalid token.

But why I didn't get this invalid token via feedback service?

You only get results when there is something to show. Results are shown one time, after that it is deleted so you should handle it immediatly when received

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM