我正在尝试实现apns-php,发现在我的测试环境中有一些无效的令牌(随着测试设备转移到生产环境中)。
我需要从数组中的序列化对象获取令牌ID,因为我想捕获此场景并从数据库中删除无效的令牌。我使用以下代码,但这不起作用:

    $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_消息是$error['message']中的序列化对象,我记不得如何访问该对象中的令牌…
VAR转储:
[“消息”]=>
对象(apnshpu消息)9(8){
[“_bautoAdjustLongPayload:受保护”]=>
布尔(真)
[“\u adevicetokens:受保护”]=>
数组(1){[0]=>字符串(64)
“018E4B9CB8CF73341CE4EBE7138E25E605CD80FB74B3A9701CE5CCA6D9363F3A”
}[“\stext:protected”]=>空
[“_nbadge:protected”]=>整数(256)
[“\u ssound:protected”]=>空
[“_acustomproperties:受保护”]=>
空[“_nexpiryvalue:protected”]=>
INT(604800)
[“_mcustomidentifier:protected”]=>
字符串(17)“message-badge-004”}

最佳答案

$error['MESSAGE']->_aDeviceTokens[0]

07-28 02:49
查看更多