从没有中间件的 AIR 桌面客户端发送推送通知(例如 PHP) [英] Send push notifications from AIR desktop client without middleware (eg. PHP)

查看:16
本文介绍了从没有中间件的 AIR 桌面客户端发送推送通知(例如 PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此 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);

?>

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

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.

问题:理论上是否可以仅使用 AS3 和 AIR(即没有 PHP)来做同样的事情?有人试过吗?除了防火墙问题,还有什么可能最终导致问题?谢谢.

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.

推荐答案

请原谅我在这里偏离目标,但你看过 ANE 的吗?

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

有一个 iOS ANE,它看起来可以让您从掌上电脑发送本机推送,而无需 php.

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

这篇关于从没有中间件的 AIR 桌面客户端发送推送通知(例如 PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆