Mojo::APNS - Apple Push Notification Service for Mojolicious
0.07
This module provides an API for sending messages to an iPhone using Apple Push Notification Service.
This module does not support password protected SSL keys.
NOTE! This module will segfault if you swap "key" and "cert" around.
use Mojo::APNS; my $apns = Mojo::APNS->new( key => '/path/to/apns-dev-key.pem', cert => '/path/to/apns-dev-cert.pem', sandbox => 0, ); $apns->on(drain => sub { $apns->loop->stop; }) $apns->send( "c9d4a07c fbbc21d6 ef87a47d 53e16983 1096a5d5 faa15b75 56f59ddd a715dff4", "New cool stuff!", badge => 2, ); $apns->on(feedback => sub { my($apns, $feedback) = @_; warn "$feedback->{device} rejected push at $feedback->{ts}"; }); $apns->ioloop->start;
Emitted when an error occur between client and server.
Emitted once all messages have been sent to the server.
$self->on(feedback => sub { my($self, $data) = @_; # ... });
This event is emitted once a device has rejected a notification. $data is a hash-ref:
$data
{ ts => $rejected_epoch_timestamp, device => $device_token, }
Once you start listening to "feedback" events, a connection will be made to Apple's push notification server which will then send data to this callback.
Path to apple SSL certificate.
Path to apple SSL key.
Booleand true for talking with "gateway.sandbox.push.apple.com" instead of "gateway.push.apple.com". Default is true.
Holds a Mojo::IOLoop object.
Same as "on" in Mojo::EventEmitter, but will also set up feedback connection if the event is "feedback".
$self->send($device, $message, %args); $self->send($device, $message, %args, $cb);
Will send a $message to the $device. %args is optional, but can contain:
$message
$device
%args
$cb will be called when the messsage has been sent or if it could not be sent. $error will be false on success.
$cb
$error
$cb->($self, $error);
badge
The number placed on the app icon. Default is 0.
sound
Default is "default".
Custom arguments
Glen Hinkle - tempire@cpan.org
tempire@cpan.org
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Mojo::APNS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::APNS
CPAN shell
perl -MCPAN -e shell install Mojo::APNS
For more information on module installation, please visit the detailed CPAN module installation guide.