tôi đã gửi thông báo trong các phiên bản cũ của ios. nhưng trong phiên bản mới hơn, tôi không thể tạo tệp .pem. Có người nói với tôi rằng tập tin pem không còn cần thiết để gửi thông báo từ máy chủ. Nhưng với may mắn tôi không thể tìm thấy bất kỳ liên kết nào về vấn đề này. Ai đó vui lòng hướng dẫn tôi cách gửi thông báo đẩy từ máy chủ trong phiên bản mới hơn của ios. Tôi bị kẹt khi gửi thông báo kể từ tuần trước. Hãy giúp tôi. Đây là mã tôi đang sử dụngcách gửi thông báo đẩy trong ios từ máy chủ bằng cách sử dụng php trong phiên bản mới hơn của ios, mà không cần sử dụng tệp pem
private function pushnotification($deviceToken, $message, $type, $badge, $userid, $jobid) {
$passphrase = '123456';
$ctx = stream_context_create();
// $file = base_path(). "/public/WenderCastPush.pem";
//stream_context_set_option($ctx, 'ssl', 'local_cert', $file);
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
stream_context_set_option($ctx, 'ssl', 'verify_peer_name', false);
stream_context_set_option($ctx, 'ssl', 'allow_self_signed', true);
//stream_context_set_option($ctx, 'ssl','ciphers', 'TLSv1');
// Open a connection to the APNS server
// $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
$body['aps'] = array(
//'badge' => +1,
'alert' => $message,
'sound' => 'default',
//'title' => $message,
'type' => $type,
'userid' => $userid ,
'jobid' => $jobid,
);
// Encode the payload as JSON
$payload = json_encode($body);
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
$responce = 'Message not delivered' . PHP_EOL;
else
$responce = 'Message successfully delivered' . PHP_EOL;
// Close the connection to the server
fclose($fp);
return $responce;
}
bạn đã thử bất cứ điều gì @Gaurav Malik –
có vui lòng câu hỏi cập nhật –
Mặc dù bạn không cần sử dụng Thông báo đẩy Bluemix, bạn có thể sử dụng Bước 2 của tài liệu để giải quyết vấn đề của bạn https://console.bluemix.net/docs/services/mobilep ush/push_step_1.html # push_step_1. Chứng chỉ p12 được tạo có thể được sử dụng với tập lệnh php –