I am trying to implement APNS-PHP and found that in my test environment I have several invalid tokens (since the test devices switched to production).
I need to get the token identifier from a serialized object in an array, since I want to catch this script and remove invalid tokens from the database. I am using the following code, but this does not work:
$aErrorQueue = $push->getErrors(); if (!empty($aErrorQueue)) { foreach($aErrorQueue as $error){ foreach($error['ERRORS'] as $err){ $message .= $err['statusMessage'] . " "; if($err['statusCode'] == 8){ $phones = Phone::getPhonesWithToken($error['MESSAGE']['_aDeviceTokens:protected'][0]); Phone::setToken($phones[0]['id'], ""); } } } }
The problem is that APNS_Message is a serialized object in $ error ['MESSAGE'], and I donβt remember how to access the token in this object ...
Reset Var:
["MESSAGE"] => object (ApnsPHP_Message) # 9 (8) {["_bAutoAdjustLongPayload: protected"] => BOOL (true) ["_aDeviceTokens: protected"] => array (1) {[0] => string (64) "018E4B9CB8CF73341CE4EBE7138E25E605CD80FB74B3A9701CE5CCA6D9363F3A"} ["_sText: protected"] => NULL ["_nBadge: protected"] => int (256) ["_sSound :ULL" protected =]>> =)> =) ["_nExpiryValue: protected"] => Int (604800) ["_mCustomIdentifier: protected"] => string (17) "Message-Badge-004"}
source share