我正在尝试实现APNS,并发现在我的测试环境中,我有一些无效的令牌(当测试设备转移到生产中时)。
我需要从数组中的序列化对象中获取令牌ID,因为我想捕捉这个场景并从DB中删除无效的令牌。我使用以下代码,但这不起作用:
$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'], "");
}
}
}
}问题是APNS_Message是$error‘’MESSAGE‘中的序列化对象,我不记得如何访问该对象中的令牌.
Var转储:
"MESSAGE"=> object(ApnsPHP_Message)#9 (8) { "_bAutoAdjustLongPayload:protected"=> bool(真) "_aDeviceTokens:protected"=>数组(1){ => string(64) =>} "_sText:protected"=> NULL "_nBadge:protected"=> int(256) "_sSound:protected"=> NULL“_aCustomProperties:protected "_aCustomProperties:protected"=> NULL”_nExpiryValue:protected“int(604800)”_mCustomIdentifier:protected"=> string(17)“消息-徽章-004”}
发布于 2011-04-04 16:17:10
$error['MESSAGE']->_aDeviceTokens[0]
发布于 2013-04-18 22:30:12
_aDeviceTokens是一个受保护的属性,您会发现直接访问该属性将引发异常。
相反,您应该在getRecipients()对象上使用Message或getRecipient($recipientNumber = 0)方法来检索设备令牌。
例如:
$token = $error['MESSAGE']->getRecipient();https://stackoverflow.com/questions/5537619
复制相似问题