AnyEvent-APNS
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
0.10 2012-11-28T09:22:31+09:00
- use enhanced notification format (mash)
- added last_identifier, on_error_response property (mash)
0.09 2012-08-28T15:54:19+09:00
- Fixed read error wasn't occurred correctly because didn't start read event watcher.
- Added optional on_eof handler.
0.08 2012-08-27T18:27:56+09:00
- Added an option that accepts certificate and private_key datas directly instead of its file path. (shin1rosei)
0.07 2010-02-16T14:08:32+09:00
- fix reconnect issue: ->connect warn 'already connected' but sometimes actially already be disconnected
0.06 2009-10-15T17:19:13+09:00
- cast badge number to int value explicitly
- fix a bug trimming wring target... s/$payload->{alert}/$payload->{aps}{alert}/.
0.05 2009-10-07T12:54:58+09:00
- now send method trimmed payload body if its length over 256bytes;
lib/AnyEvent/APNS.pm view on Meta::CPAN
use JSON::Any;
our $VERSION = '0.10';
has certificate => (
is => 'rw',
isa => 'Str | ScalarRef',
required => 1,
);
has private_key => (
is => 'rw',
isa => 'Str | ScalarRef',
required => 1,
);
has sandbox => (
is => 'rw',
isa => 'Bool',
default => 0,
);
t/02_trim.t view on Meta::CPAN
my $payloads = [
{ aps => { alert => 'ããã«ã¡ã¯'x100, } },
{ aps => { alert => { body => 'ããã«ã¡ã¯'x100, } } },
];
for my $payload (@$payloads) {
my $apns; $apns = AnyEvent::APNS->new(
debug_port => $port,
certificate => 'dummy',
private_key => 'dummy',
on_error => sub { die $! },
on_connect => sub {
$apns->send('d' x 32 => $payload);
},
);
my $cv = AnyEvent->condvar;
# test server
my $connect_state = 'initial';
t/03_validate.t view on Meta::CPAN
use Test::TCP;
plan tests => 4;
my $port = empty_port;
lives_ok {
my $apns; $apns = AnyEvent::APNS->new(
debug_port => $port,
certificate => 'dummy',
private_key => 'dummy',
);
} 'set certificate and private_key ok';
lives_ok {
my $apns; $apns = AnyEvent::APNS->new(
debug_port => $port,
certificate => \'dummy',
private_key => \'dummy',
);
} 'set certificate ref and private_key ref ok';
throws_ok {
my $apns; $apns = AnyEvent::APNS->new(
debug_port => $port,
private_key => 'dummy',
);
} qr/certificate.+is required/
, 'not set certificate';
throws_ok {
my $apns; $apns = AnyEvent::APNS->new(
debug_port => $port,
certificate => 'dummy',
);
} qr/private_key.+is required/
, 'not set private_key';
# close immediately
close $fh;
};
# without on_eof
$cv = AnyEvent->condvar;
my $apns; $apns = AnyEvent::APNS->new(
debug_port => $port,
certificate => \'',
private_key => \'',
on_error => sub {
my ($h, $fatal, $msg) = @_;
like $msg, qr/^Unexpected end-of-file/, 'eof ok';
$cv->send;
},
);
$apns->connect;
$cv->recv;
# on_eof
$cv = AnyEvent->condvar;
$apns = AnyEvent::APNS->new(
debug_port => $port,
certificate => \'',
private_key => \'',
on_error => sub {
my ($h, $fatal, $msg) = @_;
fail 'on_eof not called: ' . $msg;
$cv->send;
},
on_eof => sub {
my ($h) = @_;
pass 'on_eof called ok';
$cv->send;
},
my $cer = "$ENV{HOME}/dev/apns/test.cer";
my $key = "$ENV{HOME}/dev/apns/test.key";
my $token = file("$ENV{HOME}/dev/apns/token.bin")->slurp;
{
my $cv = AnyEvent->condvar;
my $apns; $apns = AnyEvent::APNS->new(
certificate => $cer,
private_key => $key,
sandbox => 1,
on_connect => sub {
$apns->send($token => { aps => { alert => "ãã¹ãï¼" }});
$apns->handler->on_drain(sub { undef $_[0]; $cv->send });
},
)->connect;
$cv->recv;
ok(1, "app runs ok, check your phone");
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.961 second using v1.00-cache-2.02-grep-82fe00e-cpan-dad7e4baca0 )