Welcome all! I am currently implementing an Apples Push notification feedback service. I have a pushing part, and they all work both in the sandbox and in distribution applications. However, the feedback service does not seem to be working. Every time I try to use my function .. the page is fine .. just gets a timeout.
I followed this answer to make my function: PHP technology to request APN feedback server
Here is my full functional code:
function checkFeedbackServer($appBundle,$useDev = TRUE) { $apnsPort = 2195; $apnsCert = keyForApp($appBundle,$useDev); if($useDev) { echo 'FEEDBACK in DEVELOPER MODE <br/>'; $apnsHost = 'feedback.sandbox.push.apple.com'; } else { echo 'FEEDBACK in DISTRIBUTION MODE <br/>'; $apnsHost = 'feedback.push.apple.com'; } $finalPath = 'ssl://' . $apnsHost . ':' . $apnsPort; echo 'OPENING STREAM TO -> ' . $finalPath . '<br/>'; echo 'USING CERT : ' . $apnsCert . "<br/>"; $stream_context = stream_context_create(); stream_context_set_option($stream_context, 'ssl', 'local_cert', $apnsCert); $apns = stream_socket_client($finalPath, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $stream_context); if(!$apns) { echo "ERROR $errcode: $errstr\n"; return; } else echo 'APNS FEEDBACK CONNECTION ESTABLISHED...<br/>'; $feedback_tokens = array(); $count = 0; echo 'error= ' . $error . '<br/>'; echo 'errorString= ' . $errorString . '<br/>'; if(!feof($apns)) echo 'APNS NOT FINISHED <br/>'; else echo 'APNS FINISHED? <br/>'; $result = fread($apns, 38); echo 'result= ' . $result; fclose($apns); }
I noticed that if I delete the lines:
$result = fread($apns, 38); echo 'result= ' . $result;
Then the function works correctly. Thus, in nuthsell, I can open a connection to the feedback service with both the manufacturer and the developer, but as soon as I try to get any data from my script server itβs just time.
also the keyForApp($appBundle,$useDev) function keyForApp($appBundle,$useDev) is just a simple wrapper around a request to my database that retrieves the correct certificate. I guarantee that this will work, since I also use it when clicking messages on the device.
php timeout apple-push-notifications feedback
Toolism
source share