如何判断 Apple 推送通知服务 APNS 是否处于活动状态

发布于 2024-08-01 23:01:12 字数 221 浏览 7 评论 0原文

我们正在测试一个具有 APNS 的应用程序,并注意到有时沙箱环境的 APNS 服务会停止“推送”。 苹果服务器成功接收消息,没有错误。 反馈服务也没有传入消息(我们已成功收到其他事情的反馈)。 我们此功能的代码库已经有一段时间没有改变了,而且一直运行得非常稳定。

我的问题是,Apple 是否可以发送某种 ping 来让我们知道沙箱 APNS 处于活动状态并正在运行?

谢谢。

We are testing an application that has APNS and have noticed that sometimes the APNS service for the sandbox environment stops "pushing". The message is successfully received by the apple server, no errors. There are no incoming messages from the feedback service either (we have successfully received feedback on other things). Our codebase for this feature has not changed in a while and has been working rock solid.

My question is, does Apple have some kind of ping that we can send to let us know that the sandbox APNS is alive and working?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人间☆小暴躁 2024-08-08 23:01:12

AFAIK,判断服务是否无法正常工作的唯一方法是您的套接字连接是否有问题。

在测试中,我确实发现我的 deviceId 有一次不正确,导致我无法接收消息。

另外,并不是所有的消息传递都得到保证,我相信只有最后发送的消息是得到保证的。 您是否收到来自批次的任何消息?

最后一个问题是您正在测试的设备类型,iPod Touch 不会像 iPhone 那样受到推动。

如果您这边的一切都检查完毕,也许您应该向苹果提交错误报告/功能请求。 Apple Bug Reporter 从苹果开发者论坛来看,这是一个非常需要的功能。

AFAIK, the only way to tell if the service is not working is if your socket connection has issues.

In testing I did find that my deviceId was incorrect at one point and was preventing me from receiving the messages.

Also, not all message delivery is guaranteed, I believe that only the last one sent is guaranteed. Are you receiving any messages from the batch?

The last question would be the type of device that you are testing with, iPod Touches don't get a push the same way that the iPhone does.

If everything on your side checks out maybe you should file a bug report/feature request with apple. Apple Bug Reporter From the apple dev forums it seems like this is a much requested feature.

勿忘心安 2024-08-08 23:01:12

我尝试了以下代码(PHP)

$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apple_push_notification_production.pem';

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
if($apns)
{
    echo "Connection Established<br/>";
    $deviceToken = '**********';//masked

    $body = array();
    $body['aps'] = array(’alert’ => "test message");
    //$body['aps']['badge'] = 1;

    $payload = json_encode($body);


    $apnsMessage = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
    print "sending message :" . $apnsMessage . "<br/>";
    print "sending payload :" . $payload . "<br/>";
    //fwrite($apns, $apnsMessage);

}
else
{   
    echo "Connection Failed";

    echo $errorString;
    echo $error;
}
socket_close($apns);
fclose($apns);  

回复已建立连接
正在发送消息 :�� d^÷Îå0ZCd%1äuwOOYš'ÊÈ}ârðm⁄Í�,{"aps":{"\u2019alert\u2019":"测试消息"}}
发送有效负载:{“aps”:{“\u2019alert\u2019”:“测试消息”}}

但无法获得通知

任何帮助?

i tried the following code (PHP)

$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apple_push_notification_production.pem';

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
if($apns)
{
    echo "Connection Established<br/>";
    $deviceToken = '**********';//masked

    $body = array();
    $body['aps'] = array(’alert’ => "test message");
    //$body['aps']['badge'] = 1;

    $payload = json_encode($body);


    $apnsMessage = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
    print "sending message :" . $apnsMessage . "<br/>";
    print "sending payload :" . $payload . "<br/>";
    //fwrite($apns, $apnsMessage);

}
else
{   
    echo "Connection Failed";

    echo $errorString;
    echo $error;
}
socket_close($apns);
fclose($apns);  

reply is Connection Established
sending message :�� d^÷Îå0ZCd%1ÄuwOOYš'ÊÈ}ârðm¾Í�,{"aps":{"\u2019alert\u2019":"test message"}}
sending payload :{"aps":{"\u2019alert\u2019":"test message"}}

But am not able to get the notification

any help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文