I'm writing my push notifications script in PHP. the $deviceToken
is correct, but I've a warning in this line:
$b = pack('H*', str_replace(' ', '', $deviceToken));
the warning is this:
Warning: pack() [function.pack]: Type H: illegal hex digit in /myurl.com/send_push_notification.php on line 33
And the notification doesn't arrive.
Do you know why?
I had the same problem. I ended up using
trim($device_token)
instead of
str_replace(' ', '', $deviceToken)
Fixed the issue in the end.
I had the same problem. Finally, I found that there was a space character in my URL! So, just check your URL, perhaps that's the error.
I also suffered from the same problem. It solved my issue. try using below code:
chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $item[0])) . chr(0) . chr(strlen($payload)) . $payload;
如果仍然有此问题,请尝试
$deviceToken = pack('H*', str_replace(' ', '', sprintf('%u', CRC32($deviceToken))));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.