| Net-APNS-Persistent documentation | Contained in the Net-APNS-Persistent distribution. |
Net::APNS::Feedback - Retrieve data from Apple's APNS feedback service
use Net::APNS::Feedback;
my $apns = Net::APNS::Feedback->new({
sandbox => 1,
cert => 'cert.pem',
key => 'key.pem',
passwd => 'key password',
});
my @feedback = $apns->retrieve_feedback;
Apple's APNS system provides a feedback service to let you know the device rejected notifications because they are no longer wanted (usually meaning the app has been removed).
See the|SEE ALSO Apple Push Notification Service Programming Guide.
Args:
set to true if you want to use the sandbox host. defaults to 0. ignored if you set the host manually
path to your certificate
defaults to PEM - see Net::SSLeay.
path you your private key
defaults to PEM - see Net::SSLeay.
password for your private key, if required.
defaults to feedback.push.apple.com or feedback.sandbox.push.apple.com depending on the setting of sandbox. can be set manually.
defaults to 2196
NB: all these args are available as accessors, but you need to set them before the connection is first used.
Takes no arguments and returns an arrayref (possibly) containing hashrefs. eg:
[
{
'time_t' => 1259577923,
'token' => '04ef31c86205...624f390ea878416'
},
{
'time_t' => 1259577926,
'token' => '04ef31c86205...624f390ea878416'
},
]
time_t is the epoc time of when the notification was rejected. token is
a hex encoded device token for you to reconcile with your data.
As you can see from this example, you can recieve more than one notifications about the same token if you have had more than one message rejected since you last checked the feedback service.
Note that once you have drained all the feedback, you will not be delivered the same set again.
See the|SEE ALSO Apple Push Notification Service Programming Guide.
Disconnect the ssl connection and socket, and free the ssl structures. This usually isn't necessary as this will happen implicitly when the object is destroyed.
Mark Aufflick, <mark@aufflick.com>, http://mark.aufflick.com/
Copyright (C) 2009 by Mark Aufflick
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.
| Net-APNS-Persistent documentation | Contained in the Net-APNS-Persistent distribution. |
package Net::APNS::Feedback; use 5.008; use strict; use warnings; our $VERSION = '0.02'; use base 'Net::APNS::Persistent::Base'; use JSON::XS; # ensure we're in byte-oriented mode use bytes; my %defaults = ( host_production => 'feedback.push.apple.com', host_sandbox => 'feedback.sandbox.push.apple.com', port => 2196, );
sub new { my ($class, $init_vals) = @_; $init_vals ||= {}; my $self = $class->SUPER::new({ %defaults, %{$init_vals} }); return $self; }
sub retrieve_feedback { my $self = shift; my $data = $self->_read; my @res; while ($data) { my ($time_t, $token_bin); ($time_t, $token_bin, $data) = unpack( 'N n/a a*', $data); push @res, { time_t => $time_t, token => unpack( 'H*', $token_bin ), }; } return \@res; }
1;