Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8159521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:56:49+00:00 2026-06-06T17:56:49+00:00

The push works just fine, the problem is that the feedback is empty. I

  • 0

The push works just fine, the problem is that the feedback is empty. I need to delete the tokens that have expired or have an invalid status.
Here is my push code:

// Push code example
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certificateName);
//stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
//stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

// Open a connection to the APNS server
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

if (!$fp) {
    exit("Failed to connect: $err $errstr" . PHP_EOL);
}

// Create the payload body
$body['aps'] = array(
    'alert' => $message,
    'sound' => 'default'
);

// Encode the payload as JSON
$payload = json_encode($body);

// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));

if (!$result) {
    echo '<p>The message has not been sent '. PHP_EOL;
} else {
    echo '<p>The message has been sent  ' . PHP_EOL;
}

// Close the connection to the server
fclose($fp);

And for the feedback code I have tried
1.

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certificateName);
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
// assume the private key passphase was removed.
// stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);

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

if (!$fp) {
    //echo "Failed to connect feedback server: $err $errstr\n";
    return;
} else {
  // echo "Connection to feedback server OK\n";
}

echo "APNS feedback results\n";
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 . "\n";
    echo "DEVICE ID:" . $feedbackDeviceToken. "\n\n";
}
fclose($fp);

and the result is empty.

2.
// set default timezone
date_default_timezone_set(‘Europe/Bucharest’);

// Report all PHP errors
error_reporting(-1);

// Using Autoload all classes are loaded on-demand
//require_once 'ApnsPHP/Autoload.php';
$feedback = new ApnsPHP_Feedback(
    ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
    $certificateName
);

// Connect to the Apple Push Notification Feedback Service
$feedback->connect();

$aDeviceTokens = $feedback->receive();
if (!empty($aDeviceTokens)) {
    var_dump($aDeviceTokens . '<br><br>');
}



// Disconnect from the Apple Push Notification Feedback Service
$feedback->disconnect();

Also with an empty result

3.

// create context stream
$stream_context = stream_context_create();

stream_context_set_option($stream_context, 'ssl', 'local_cert', $certificateName);
stream_context_set_option($streamContext, 'ssl', 'verify_peer', false);
$apns = stream_socket_client('ssl://feedback.sandbox.push.apple.com:2196', $errcode, $errstr, 60, STREAM_CLIENT_CONNECT, $stream_context);
if (!$apns) {
    echo "ERROR $errcode: $errstr\n";
} else {
    $feedback_tokens = array();
    //and read the data on the connection:
    while (!feof($apns)) {
        $data = fread($apns, 38);
        if (strlen($data)) {
            $feedback_tokens[] = unpack("N1timestamp/n1length/H*devtoken", $data);
        }
    }
    var_dump($feedback_tokens);

Also with an empty result…. please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:56:51+00:00Added an answer on June 6, 2026 at 5:56 pm

    Apple sandbox feedback server seems to return no inactive tokens, although production environment seems to be working fine.
    Have a look at this thread: Apple Push Notification Feedback Service – how frequently does it check

    Suggested solution is to have two development apps on your device and then to delete one. The deleted one should appear in the list of inactive tokens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a little push in the right direction. Here's my problem: I have
We have a web site that uses extensively jQuery and it works fine in
I have tested the encryption part of the program and it works just fine
In a normal/synchronous/single-threaded console app, NDC.Push works fine for managing the 'current item' (potentially
I'm making a chat application that works with long-polling to emulate a push from
I have been trying to set up a program that sends a push notification
I have an app that is using push notifications with apples APNS. Most of
My app, in my filesystem, works just fine. All tests pass. I'm a sole
I want to use push notification in my app.i want to know that do
I have a popover containing a UINavigationController. I can display the popover fine, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.