gpt4 book ai didi

php - 向许多设备 token 发送推送通知

转载 作者:可可西里 更新时间:2023-11-01 03:33:19 25 4
gpt4 key购买 nike

<分区>

我有这个 PHP 脚本:

$q = mysql_query("SELECT `token` FROM `tokens`");

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


while($token = mysql_fetch_array($q))
{
$deviceToken = $token[0];
echo $deviceToken.": ";
$payload['aps'] = array('alert' => $message, 'sound' => 'Completed.wav');
$payload = json_encode($payload);

if (!$fp)
{
echo "Failed to connect {$err} {$errstrn}<br />";
}
else
{
echo "Connection OK<br />";
}

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

if (fwrite($fp, $msg, strlen($msg)) === FALSE)
{
echo "can't write to socket!<br />";
}
}

fclose($fp);

所有 token 的结果 - 连接正常!但是只有一台设备收到推送通知!我尝试发送不同的消息,但结果没有改变:(

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com