line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::APNS::Feedback; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
61049
|
use 5.008; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
65
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
243
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use base 'Net::APNS::Persistent::Base'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1856
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
2394
|
use JSON::XS; |
|
2
|
|
|
|
|
19265
|
|
|
2
|
|
|
|
|
151
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ensure we're in byte-oriented mode |
14
|
2
|
|
|
2
|
|
18
|
use bytes; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
25
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %defaults = ( |
17
|
|
|
|
|
|
|
host_production => 'feedback.push.apple.com', |
18
|
|
|
|
|
|
|
host_sandbox => 'feedback.sandbox.push.apple.com', |
19
|
|
|
|
|
|
|
port => 2196, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Net::APNS::Feedback - Retrieve data from Apple's APNS feedback service |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Net::APNS::Feedback; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $apns = Net::APNS::Feedback->new({ |
31
|
|
|
|
|
|
|
sandbox => 1, |
32
|
|
|
|
|
|
|
cert => 'cert.pem', |
33
|
|
|
|
|
|
|
key => 'key.pem', |
34
|
|
|
|
|
|
|
passwd => 'key password', |
35
|
|
|
|
|
|
|
}); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my @feedback = $apns->retrieve_feedback; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Apple's APNS system provides a feedback service to let you know the |
42
|
|
|
|
|
|
|
device rejected notifications because they are no longer wanted |
43
|
|
|
|
|
|
|
(usually meaning the app has been removed). |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
L Apple Push Notification Service Programming Guide. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Args: |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=over |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item sandbox |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
set to true if you want to use the sandbox host. defaults to 0. ignored if you set the host manually |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item cert |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
path to your certificate |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item cert_type |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
defaults to PEM - see L. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item key |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
path you your private key |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item key_type |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
defaults to PEM - see L. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item passwd |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
password for your private key, if required. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item host |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
defaults to feedback.push.apple.com or feedback.sandbox.push.apple.com depending |
82
|
|
|
|
|
|
|
on the setting of sandbox. can be set manually. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item port |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
defaults to 2196 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
NB: all these args are available as accessors, but you need to set them before the connection |
91
|
|
|
|
|
|
|
is first used. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub new { |
96
|
0
|
|
|
0
|
1
|
|
my ($class, $init_vals) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
0
|
|
|
|
$init_vals ||= {}; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new({ |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
%defaults, |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
%{$init_vals} |
105
|
|
|
|
|
|
|
}); |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return $self; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 retrieve_feedback |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Takes no arguments and returns an arrayref (possibly) containing hashrefs. eg: |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
[ |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
'time_t' => 1259577923, |
117
|
|
|
|
|
|
|
'token' => '04ef31c86205...624f390ea878416' |
118
|
|
|
|
|
|
|
}, |
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
'time_t' => 1259577926, |
121
|
|
|
|
|
|
|
'token' => '04ef31c86205...624f390ea878416' |
122
|
|
|
|
|
|
|
}, |
123
|
|
|
|
|
|
|
] |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
C is the epoc time of when the notification was rejected. C is |
126
|
|
|
|
|
|
|
a hex encoded device token for you to reconcile with your data. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
As you can see from this example, you can recieve more than one notifications |
129
|
|
|
|
|
|
|
about the same token if you have had more than one message rejected since you last |
130
|
|
|
|
|
|
|
checked the feedback service. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Note that once you have drained all the feedback, you will not be delivered the |
133
|
|
|
|
|
|
|
same set again. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L Apple Push Notification Service Programming Guide. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub retrieve_feedback { |
140
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
my $data = $self->_read; |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my @res; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
while ($data) { |
147
|
0
|
|
|
|
|
|
my ($time_t, $token_bin); |
148
|
0
|
|
|
|
|
|
($time_t, $token_bin, $data) = unpack( 'N n/a a*', $data); |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
push @res, { |
151
|
|
|
|
|
|
|
time_t => $time_t, |
152
|
|
|
|
|
|
|
token => unpack( 'H*', $token_bin ), |
153
|
|
|
|
|
|
|
}; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
return \@res; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 disconnect |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Disconnect the ssl connection and socket, and free the ssl structures. This usually |
162
|
|
|
|
|
|
|
isn't necessary as this will happen implicitly when the object is destroyed. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SEE ALSO |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over 4 |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item Presentation on this module by Author |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item Apple Push Notification Service Programming Guide |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item L |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item GIT Source Repository for this module |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=back |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Mark Aufflick, Emark@aufflick.comE, L |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Copyright (C) 2009 by Mark Aufflick |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
193
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.9 or, |
194
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; |