gpt4 book ai didi

iphone - Apple 推送通知服务 - 设备上没有通知

转载 作者:行者123 更新时间:2023-12-03 20:35:24 24 4
gpt4 key购买 nike

这个问题快把我逼疯了。我正在实现 APNS。我已经谷歌搜索并遵循了几个教程。我实现了服务器,它似乎可以工作,这里是代码:

<?php

$deviceToken = 'XXXX';
// Passphrase for the private key (ck.pem file)
// $pass = '';
// Get the parameters from http get or from command line
$message = $_GET['message'] or $message = $argv[1] or $message = 'Message received from javacom';
$badge = (int)$_GET['badge'] or $badge = (int)$argv[2];
$sound = $_GET['sound'] or $sound = $argv[3];

// Construct the notification payload
$body = array();
$body['aps'] = array('alert' => $message);
if ($badge)
$body['aps']['badge'] = $badge;

if ($sound)
$body['aps']['sound'] = $sound;

/* End of Configurable Items */

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
// assume the private key passphase was removed.
//stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); // for production change the server to ssl://gateway.push.apple.com:219
if (!$fp) {
print "Failed to connect $err $errstr\n";
return;
} else {
print "Connection OK\n";
}

$payload = json_encode($body);
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
print "sending message :" . $payload . "\n";
fwrite($fp, $msg);
fclose($fp);

?>

看起来效果不错。我没有收到任何错误。但我的设备上没有收到任何推送通知。我不知道错误可能出在哪里。我还实现了反馈脚本。没有错误,也没有输出。我的App也准备好了。提前致谢。

最佳答案

Apple刚刚发布了一份名为 "Troubleshooting Push Notifications" 的技术说明。它有发送和接收的提示。也许那里有什么可以帮忙的。

关于iphone - Apple 推送通知服务 - 设备上没有通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3868274/

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