简体   繁体   English

设备令牌无效时将推送通知发送到ios设备崩溃

[英]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.

相关问题 向APP发送推送通知,无需设备令牌或注册ID - Send push notification to APP without device token or register id 使用APNS和使用PHP的DataService向iOS设备发送推送通知 - Send Push notification to IOS Device using APNS and DataService using PHP 如何将推送通知从 Firebase 发送到 iOS 设备上的 web 应用程序? - How to send push notification from Firebase to web app on iOS device? 使用 php 将带有 fcm 令牌的远程通知发送到 ios 设备 - send remote notification with fcm token to ios device using php 无效令牌时,向iOS设备的推送通知失败 - Push notification to iOS devices fails when invalid token 将推送通知发送到iOS测试设备时发生PHP错误 - PHP error when sending Push Notification to iOS test device Iphone推送通知设备令牌错误 - Iphone Push Notification Wrong Device Token 如何将Chrome推送通知发送到多个设备 - How to send Chrome push notification to mulitple device 城市飞艇-将PUSH发送到1个特定设备(设备令牌) - Urban Airship - send PUSH to 1 specific device (device token) 如何在Laravel 5.1中使用AWS SNS将推送通知从Web发送到iOS和android设备? - How to send push notification from web to iOS and android device using AWS SNS in Laravel 5.1?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM