小编sai*_*oid的帖子

使用计划任务使用PHP服务器脚本进行iOS推送通知

我正在为Apple设备实现推送通知服务。使用php脚本,仅当php脚本从浏览器中命中时,它才推送通知。当我通过浏览器点击服务器php脚本时,它将通知推送到Apple设备。我的PHP脚本是...

//在Apple设备中发送通知的方法的结尾

function sendNotificationToAppleDevice($token,$message)
    {
    /////////////////////////////////////////////For apple divice////////////////////////////////

$passphrase='1234';
// Create a stream to the server
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', 'sample.pem');
stream_context_set_option($streamContext, 'ssl', 'passphrase', $passphrase);

$apns = stream_socket_client( 'ssl://gateway.sandbox.push.apple.com:2195', $error,$errorString,60,STREAM_CLIENT_CONNECT, $streamContext);

// You can access the errors using the variables $error and $errorString


// Now we need to create JSON which can be sent to APNS
        $inc=0;                  
$load = array(
'aps' => array(
'alert' => $message,
'badge' =>$inc,
)
);
$inc++;
$payload = json_encode($load);
// The payload needs …
Run Code Online (Sandbox Code Playgroud)

cron push-notification ios

1
推荐指数
1
解决办法
1740
查看次数

标签 统计

cron ×1

ios ×1

push-notification ×1