Closed tanner0101 closed 8 years ago
You can't, apple closes connection if token is invalid. You should reconnect and resent any notifications you sent after it
Can you please give an example for how to receover from a closed connection ? In particular, my question is related to the case when sending a single message to a large number of devices.
apn_payload_set_array($payload, array(
'body' => 'This push was sent using PHP && php-apn',
'sound' => 'default',
'badge' => 34,
'tokens' => array (
'device1Token',
'device2Token',
'device3Token',
... // and many more
)
));
I'm trying to retrieve the devices invalids tokens
if (apn_feedback_connect($apn, $error, $errcode)) {
$tokens = apn_feedback($apn, $error, $errcode);
if ( ! is_array($tokens)) {
echo 'Failed to obtain device tokens: ' . $error;
} else {
foreach($tokens as $token) {
echo 'Token: '.$token;
}
}
} else {
echo 'Failed to connect to Apple Push Feedback Service: ' . $error;
}
Previously I'm forcing invalid devices tokens but still this is returning me $tokens
empty array.
apn_feedback shan't return invalid tokens. It's return tokens from removed app
The Apple Push Notification service includes a feedback service to give you information about failed remote notifications. When a remote notification cannot be delivered because the intended app does not exist on the device, the feedback service adds that device’s token to its list
Ahh ok, @adobkin thank you very much!
I have a couple thousand devices I am trying to send a push notification to, and I keep getting this error:
message":"Could not send push invalid device token","errno":703
It is sending the push notification to some devices, but stops sending once it hits an invalid token. How can I set PHP-APN to ignore these invalid tokens or how do I get rid of them efficiently?