Tôi cũng gặp nhiều khó khăn hơn để làm điều tương tự. Cuối cùng tôi tìm thấy giải pháp để gửi thông báo đẩy thông qua url toàn cục PHP. Hãy thử các bước dưới đây. Trước đó tôi hy vọng tất cả các bạn biết để tạo ra 3 giấy chứng nhận thats PushChat.certSigningRequest, pushkey.p12 & aps_development.cer (csr, p12, cer)
Mở Terminal và từng bước chạy các lệnh dưới đây:
# Make sure terminal refers your correct certificate path.
$ cd ~/Desktop/
# Ask system administrator to open if its not connected
$ telnet gateway.sandbox.push.apple.com 2195
Trying 17.110.227.35...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.
# Convert .cer to .pem
$ openssl x509 -in aps_development.cer -inform der -out PushCert.pem
# Convert .p12 to .pem. Enter your pass pharse which is the same pwd that you have given while creating the .p12 certificate. PEM pass phrase also same as .p12 cert.
$ openssl pkcs12 -nocerts -out PushKey1.pem -in pushkey.p12
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
# To remove passpharse for the key to access globally. This only solved my stream_socket_client() & certificate capath warnings.
$ openssl rsa -in PushKey1.pem -out PushKey1_Rmv.pem
Enter pass phrase for PushChatKey1.pem:
writing RSA key
# To join the two .pem file into one file:
$ cat PushCert.pem PushKey1_Rmv.pem > ApnsDev.pem
Sau đó Cuối cùng, di chuyển tệp SimplePush.php đến vị trí tệp ApnsDev.pem. Cả hai tệp sẽ nằm trong cùng một thư mục. và thay đổi Mã thông báo thiết bị, Cụm từ mật khẩu, Tên chứng chỉ (ApnsDev.pem), Tin nhắn… Trong tệp simplepush.php Tải xuống tệp bằng URL bên dưới. http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip Sau đó chạy file trong thiết bị đầu cuối hoặc máy chủ tên miền của bạn
$ php simplepush.php
hoặc
www.Domainname.com/push/simplepush.php // Now, url shows 'Connected to APNS Message successfully delivered'.
Thats nó, thông báo push sẽ bay và đạt được các thiết bị IOS cụ thể.
Nếu bạn muốn gửi 'Badge' rồi thay đổi mã tải trọng trong simplepush.php như dưới đây,
// Construct the notification payload body:
$badge = 1;
$sound = 'default';
$body = array();
$body['aps'] = array('alert' => $message);
if ($badge)
$body['aps']['badge'] = $badge;
if ($sound)
$body['aps']['sound'] = $sound;
// End of Configurable
// Encode the payload as JSON:
$payload = json_encode($body);
Bây giờ chạy file php một lần nữa và vào biểu tượng ứng dụng xuất hiện với số huy hiệu trong vòng tròn màu đỏ.
việc này có được giải quyết không? tôi đang gặp vấn đề tương tự. –