我使用this發送推送通知Laravel
到iOS
應用程序。它對64個字符長度的令牌工作正常,但它會用長度爲54個字符的令牌拋出此錯誤。適配器Apns不支持xxxxxxxxxxxxxxxxxxxxxxx令牌的設備
我送用下面的代碼推送:
$payload = PushNotification::Message($message, array(
'badge' => 1,
'sound' => 'default',
));
PushNotification::app('appNameIOS')
->to($device_token)
->send($payload);
我想抓住這樣的例外:
catch (Exception $ex){
//do something
}
而且這樣的:
catch (PushException $ex) {
//do something
}
但並沒有發現異常並且引發這個錯誤:
Adapter Apns does not support xxxxxxxxxxxxxxxxxxxxxxx token's device
如何在發送推送前驗證令牌?
看到這個曾經https://github.com/davibennun/laravel-push-notification/issues/96 –
嘗試檢查設備令牌是有效的發送通知之前... –
是的,我已經看到了這這個硬編碼檢查令牌的長度是64,這是不正確的,因爲長度可以變化。看看這個:https://stackoverflow.com/questions/12452448/size-of-iphone-device-token – Saani