首先检查设备令牌是否正确,并确保它来自正确的设备。通常,Bad 设备令牌表示该设备不再注册或已注销推送服务。您可以通过获取最新的设备令牌并更新您的服务器上的设备令牌来解决此问题。
检查您的证书和密钥是否正确。如果您使用的是沙箱开发环境,则使用开发证书和密钥;如果您正在使用生产环境,则使用生产证书和密钥。您可以使用以下代码检查证书和密钥是否正确:
// Specify the certificate file path $certificateFile = 'path/to/certificate.pem'; // Specify the passphrase (if you are using one) $passphrase = 'myCertificatePassphrase'; // Create the stream context $streamContext = stream_context_create([ 'ssl' => [ 'local_cert' => $certificateFile, 'passphrase' => $passphrase ] ]); // Set the APNS url $url = 'ssl://gateway.push.apple.com:2195'; // Set the APNS port $port = 2195; // Connect to the APNS server $apns = stream_socket_client($url . ':' . $port, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext); // If the connection was successful, the apns variable is not null if($apns) { echo 'Connection successful!'; } else { echo 'Connection failed: ' . $errorString; }
上一篇:APNS只显示一个待处理通知。
下一篇:APN未送达