Voip push notification not received by php script

Viewed 227

iOS Version: 14.5.1 Xcode Version: 12.4

I'm using PHP to send PushKit notifications, it is normally using in the last week or early. but in these few days, can't receive anywhere. In the script, I have got "Message successfully delivered", but didReceiveIncomingPushWith always not working.

Did Anyone has been solved this problem in these few days? please help me to solve this problem.

php code:

$ctx = stream_context_create([
    'ssl' => [
        'verify_peer'      => false,
        'verify_peer_name' => false
    ]
]);

stream_context_set_option($ctx, 'ssl', 'local_cert', $pem_url);
stream_context_set_option($ctx, 'ssl', 'passphrase', $passpem);

$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
$fp_sandbox = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);

$msg = chr(0) . pack('n', 32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack('n', strlen($payload)) . $payload;

$result = fwrite($fp, $msg, strlen($msg));
$result_box = fwrite($fp_sandbox, $msg, strlen($msg));

if (!$result) {
    echo 'Product Message not delivered';
} else {
    echo 'Product Message successfully delivered';
}
if (!$result_box) {
    echo 'Sandbox Message not delivered';
} else {
    echo 'Sandbox Message successfully delivered';
}

fclose($fp);
fclose($fp_sandbox);
0 Answers
Related