[英]Send push notification to ios device crash when device token is invalid
Im trying to send push notification to multiple ios device, but when one or more tokens are invalids it crash and not send the message to the other devices, here is my code: 我试图将推送通知发送到多个ios设备,但是当一个或多个令牌无效时,它崩溃并且不将消息发送到其他设备,这是我的代码:
require_once "libs/ApnsPHP/Autoload.php";
$push = new ApnsPHP_Push(ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,'WenderCastPush.pem');
$pushdevices = array('499D3684-5039-4E56ACB7E285057E8568','21bff83127f8f307b307e828cfe4a65081b7468f980d17f9fbbda05785298c7d');
$push->connect();
foreach ($pushdevices as $device)
{
try{
$message = new ApnsPHP_Message($device);
$message->setCustomIdentifier("Message-Badge-3");
$message->setBadge(3);
$message->setText('Message Alert : Testing IOS');
$message->setSound();
$message->setExpiry(30);
$push->add(@$message);
}
catch(Exception $e)
{}
}
$push->send();
$push->disconnect();
How come you are receiving the device token as invalid ones? 您怎么会收到无效的设备令牌? Its either the developer who's is sending the token to you via web service is messing it up or there is a prob. 它是通过Web服务向您发送令牌的开发人员弄乱了令牌,还是有问题。 at you end . 在你尽头。 Simple solution to this can be , put a check on device token if its above 32 bytes don't save it . 一个简单的解决办法是,如果设备令牌的32个以上字节没有保存,请对其进行检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.