AnyEvent-APNS
view release on metacpan or search on metacpan
lib/AnyEvent/APNS.pm view on Meta::CPAN
# or
private_key => \$private_key,
Required. Either file path for private_key or scalar-ref of private-key data.
=item sandbox => 0|1
This is a flag indicate target service is provisioning (sandbox => 1) or distribution (sandbox => 0)
Optional (Default: 0)
=item on_error => $cb->($handle, $fatal, $message)
Callback to be called when something error occurs.
This is wrapper for L<AnyEvent::Handle>'s on_error callbacks. Look at the document for more detail.
Optional (Default: just warn error)
=item on_eof => $cb->($handle)
Callback to be called when an end-of-file condition is detected.
Optional. (Default: use on_error instead. read L<AnyEvent::Handle> for more detail)
=item on_connect => $cb->()
Callback to be called when connection established to apns server.
Optional (Default: empty coderef)
=item on_error_response => $cb->($identifier, $status)
Callback to be called when APNs detects notification malformed or otherwise unintelligible.
C<$status> codes are documented here: L<http://developer.apple.com/library/ios/#DOCUMENTATION/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html>
C<$identifier> is the return value of C<send>.
Optional (Default: ignore)
=back
=head2 $apns->connect;
Connect to apns server.
=head2 $apns->send( $device_token, \%payload )
Send apns messages with C<\%payload> to device specified C<$device_token>.
my $identifier = $apns->send( $device_token => {
aps => {
alert => 'Message received from Bob',
},
});
C<$device_token> should be a binary 32bytes device token provided by iPhone SDK (3.0 or above)
C<\%payload> should be a hashref suitable to apple document: L<http://developer.apple.com/iPhone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html>
Note: If you involve multi-byte strings in C<\%payload>, it should be utf8 decoded strings not utf8 bytes.
Store C<$identifier> with your C<$device_token> to react to C<on_error_response>.
=head2 $apns->handler
Return L<AnyEvent::Handle> object which is used to current established connection. It returns undef before connection completed.
=head1 TODO
=over 4
=item *
More correct error handling
=item *
Auto reconnection
=back
=head1 AUTHOR
Daisuke Murase <typester@cpan.org>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2009 by KAYAC Inc.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=cut
( run in 3.472 seconds using v1.01-cache-2.11-cpan-995e09ba956 )