php - 关于 devicetoken 的 APNS 问题不适用于 PHP 中的主题和错误的设备令牌
问题描述
我正在尝试使用此 PHP 客户端库为 VOIP 集成 APNS 的发送:
composer require edamov/pushok
我遵循了如何在$options
数组中提供正确值的步骤,我无法在此处披露。
当我尝试在以下代码中转储变量时:
$options = [
'key_id' => $keyid, // The Key ID obtained from Apple developer account
'team_id' => $teamid, // The Team ID obtained from Apple developer account
'app_bundle_id' => $bundleid, // The bundle ID for app obtained from Apple developer account
'private_key_path' => $keyfile, // Path to private key
'private_key_secret' => null // Private key secret
];
$authProvider = AuthProvider\Token::create($options);
$alert = Alert::create()->setTitle('Hello!');
$alert = $alert->setBody('First push notification');
$payload = Payload::create()->setAlert($alert);
//set notification sound to default
$payload->setSound('default');
$deviceTokens = [$token];
$notifications = [];
foreach ($deviceTokens as $deviceToken) {
$notifications[] = new Notification($payload,$deviceToken);
}
$client = new \Pushok\Client($authProvider, $production = false);
$client->addNotifications($notifications);
$responses = $client->push(); // returns an array of ApnsResponseInterface (one Response per Notification)
var_dump($responses);
这是我得到的:
array (size=1)
0 =>
object(Pushok\Response)[1564]
private 'apnsId' => string '7EEEWAYS-BE3F-P0RK-J3RK-706FC55D5ABS' (length=36)
private 'deviceToken' => string 'wlo83peah2f2ql686sfitzasro2wghri85x2l128t7gqysoba9jaezsve0y0nvpm' (length=64)
private 'statusCode' => int 400
private 'errorReason' => string 'DeviceTokenNotForTopic' (length=22)
private 'error410Timestamp' => string '' (length=0)
尽管我认为数组中HTTP400
DeviceTokenNotForTopic
提供的值是正确的,但我想询问或寻求帮助我为什么会收到错误?$options
另外,我刚刚发现,当我从这里更改 $client 的第二个参数的值时:
$client = new \Pushok\Client($authProvider, $production = false);
$client->addNotifications($notifications);
对此
$client = new \Pushok\Client($authProvider, $production = true);
$client->addNotifications($notifications);
我收到BadDeviceToken
HTTP400
错误消息:
array (size=1)
0 =>
object(Pushok\Response)[1564]
private 'apnsId' => string '733TWAYS-S0UR-F1SH-CH0W-706FC55D5ABS' (length=36)
private 'deviceToken' => string 'wlo83peah2f2ql686sfitzasro2wghri85x2l128t7gqysoba9jaezsve0y0nvpm' (length=64)
private 'statusCode' => int 400
private 'errorReason' => string 'BadDeviceToken' (length=14)
private 'error410Timestamp' => string '' (length=0)
提前致谢。
解决方案
推荐阅读
- python - 增加服务器端的 CPU 使用率
- c - 在c中填充二维数组的第二列
- shell - Shell 脚本 - 使用 sh 运行脚本时出现错误替换错误
- java - 如何正确解码和编码来自 JTextArea 的字符
- opengl-es - 关于opengl中帧缓冲区纹理的内存管理
- angular - 类中的打字稿联合
- python - mysql.connector.errors.ProgrammingError:1054(42S22):'where 子句'中的未知列'PY_VAR0'
- javascript - 如何将 javascript 函数舍入为 1.00 而不是 0.100?
- python - 卡在 Python Web 抓取中抓取 Novel 标题及其链接
- javascript - 在 reducer (redux) 中使用拼接