设备上未接收推送通知 [英] Push notification is not receiving on device
本文介绍了设备上未接收推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过PHP脚本使用推送通知。代码似乎工作正常,它不会给我任何错误。但通知不会在我的设备上收到我。
I am using push notification through PHP script. Code seems to be working fine, it does not give me any error. But notification does not receive me on my device.
这是我的代码:
$passphrase = '123';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'cert.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
任何人都可以建议它有什么问题。
Can anyone suggest what is wrong in it.
推荐答案
尝试这个PHP代码:
但你必须像设置的那样更改设备令牌和passpharse。你可以从下面链接下载php脚本
try this php code: but you have to change device token and passpharse as you had set. you can download php script from below link
http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip
我已经运行了这个PHP脚本,它运行良好..
i have run this php script it's works well..
这篇关于设备上未接收推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文