从 AIR 桌面客户端发送推送通知,无需中间件(例如 PHP)

发布于 2024-12-27 20:58:20 字数 900 浏览 0 评论 0原文

通过此 PHP 代码:

<?php
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsCert = 'apns-dev.pem';
$apnsPort = 2195;

$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);

$payload['aps'] = array('alert' => 'Oh hai!', 'badge' => 1, 'sound' => 'default');
$output = json_encode($payload);
$token = pack('H*', str_replace(' ', '', $token))
$apnsMessage = chr(0) . chr(0) . chr(32) . $token . chr(0) . chr(strlen($output)) . $output;
fwrite($apns, $apnsMessage);

socket_close($apns);
fclose($apns);

?>

您可以使用 PHP 发送推送通知。从 AIR 桌面客户端,我可以轻松地将 POST 变量传递给类似的代码,并使用 AS3+PHP 发送通知。

问题:理论上是否可以仅使用 AS3 和 AIR(即不使用 PHP)来完成相同的操作?有人尝试过吗?除了防火墙问题之外,什么最终会导致问题?谢谢。

With this PHP code:

<?php
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsCert = 'apns-dev.pem';
$apnsPort = 2195;

$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);

$payload['aps'] = array('alert' => 'Oh hai!', 'badge' => 1, 'sound' => 'default');
$output = json_encode($payload);
$token = pack('H*', str_replace(' ', '', $token))
$apnsMessage = chr(0) . chr(0) . chr(32) . $token . chr(0) . chr(strlen($output)) . $output;
fwrite($apns, $apnsMessage);

socket_close($apns);
fclose($apns);

?>

you can send a push notification using PHP. From an AIR desktop client I can easily pass POST variables to a similar code and use AS3+PHP to send a notification.

The question: is it theoretically possible to do the same by only using AS3 and AIR (that is without PHP)? Has anyone tried? Aside from firewall issues, what could eventually cause problems? Thanks.

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

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

发布评论

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

评论(2

甜尕妞 2025-01-03 20:58:20

NetGroup 类非常适合此目的。您可以将任何您想要的内容从设备 A 发送到设备 B,反之亦然,甚至可以发送到多个设备。它的工作方式有点像聊天室,但不限于字符串。

如果设备不在同一网络上,则需要通过 Adob​​e Cirrus 服务器(免费用于测试和非商业用途)或其他 FMS 服务器(例如 Adob​​e 或 Amazon 托管服务,或者您的自己的服务器)。一旦引入,它们通常通过 rtmfp 安全点对点协议直接相互通信,该协议可以穿越几乎所有防火墙。在极少数情况下,它们无法直接连接,FMS 服务器可以中继消息。

The NetGroup class is ideal for this. You can send anything you want from device A to device B and vice versa, or even multiple devices. It works sort of like a chatroom, but is not limited to strings.

If the devices are not on the same network, they'll need to be introduced to eachother via the Adobe Cirrus server (free for testing and non-commercial use) or another FMS server (such as an Adobe or Amazon hosted service, or your own server). Once introduced they normally communicate directly to eachother via the rtmfp secure peer-to-peer protocol, which can traverse almost all firewalls. In the rare case that they cannot connect directly the FMS server can relay the messages.

彩扇题诗 2025-01-03 20:58:20

如果我偏离了目标,请原谅我,但是你看过 ANE 的吗?

有一个 iOS ANE,看起来可以让您从手持设备发送本机推送,而无需 php。

http://www.raywenderlich.com/3443/apple -push-notification-services-tutorial-part-12

Forgive me if I'm off target here, but have you looked at ANE's?

There is an iOS ANE that looks like it lets you send a native push from your handheld without php.

http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12

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