AsTheWormTurns
AsTheWormTurns

Reputation: 1316

Send push notifications from AIR desktop client without middleware (eg. 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.

Upvotes: 2

Views: 1506

Answers (2)

francis
francis

Reputation: 6349

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

Upvotes: 1

Jon Webb
Jon Webb

Reputation: 33

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.

Upvotes: 1

Related Questions