APNS-Agent

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# NAME

APNS::Agent - agent server for APNS

# SYNOPSIS

    use APNS::Agent;
    my $agent = APNS::Agent->new(
        certificate => '/path/to/certificate',
        private_key => '/path/to/private_key',
    );
    $agent->run;

# DESCRIPTION

APNS::Agent is agent server for APNS. It is also backend class of [apns-agent](http://search.cpan.org/perldoc?apns-agent).

This module provides consistent connection to APNS and cares reconnection. It utilizes
[AnyEvent::APNS](http://search.cpan.org/perldoc?AnyEvent::APNS) internally.

lib/APNS/Agent.pm  view on Meta::CPAN

use Encode qw/decode_utf8/;
use JSON::XS;
use Log::Minimal;
use Plack::Request;
use Router::Boom::Method;

use Class::Accessor::Lite::Lazy 0.03 (
    new => 1,
    ro => [qw/
        certificate
        private_key
        sandbox
        debug_port
    /],
    ro_lazy => {
        on_error_response   => sub {
            sub {
                my $self = shift;
                my %d = %{$_[0]};
                warnf "identifier:%s\tstate:%s\ttoken:%s", $d{identifier}, $d{state}, $d{token} || '';
            }

t/01_basic.t  view on Meta::CPAN

            });
        });
    });
};

local $Log::Minimal::LOG_LEVEL = "NONE";

my $apns_agent = APNS::Agent->new(
    sandbox     => 1,
    certificate => 'dummy',
    private_key => 'dummy',
    debug_port  => $apns_port,
);

test_psgi
    app => $apns_agent->to_app,
    client => sub {
        my $cb  = shift;
        ok !$apns_agent->__apns->connected;

        my $req = POST 'http://localhost', [

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.762 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b )