我在ios13中遇到通知问题。如果我使用gateway.sandbox,我可以看到通知,但我已经直接从AppStore下载了应用程序。而不是使用gateway.apple,我看到了“device to APNS”,但在我的设备上什么也没有。我还尝试重新创建证书、.p12和.pem文件。
有什么想法吗?谢谢
这是我的php
public function iOS($data, $devicetoken)
{
// $tHost = 'gateway.sandbox.push.apple.com';
$tHost = 'gateway.push.apple.com';
$tPort = 2195;
$tCert = 'pushcert.pem';
$tPassphrase = 'pushcertpsw12';
$tToken = $devicetoken;
$tSound = 'default';
$tPayload = 'APNS payload';
$tBody['aps'] = array(
'apns-priority' => 10,
'badge' => +1,
'alert' => $data['mtitle'] .' ' .$data['mdesc'],
'sound' => 'default'
);
$tBody ['payload'] = $tPayload;
$tBody = json_encode ($tBody);
$tContext = stream_context_create ();
stream_context_set_option ($tContext, 'ssl', 'local_cert', $tCert);
stream_context_set_option ($tContext, 'ssl', 'passphrase', $tPassphrase);
$tSocket = stream_socket_client ('ssl://'.$tHost.':'.$tPort, $error, $errstr, 30, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $tContext);
if (!$tSocket)
exit ('APNS Connection Failed:' .$error. ' ' .$errstr . PHP_EOL);
$tMsg = chr (0) . chr (0) . chr (32) . pack ('H*', $tToken) . pack ('n', strlen ($tBody)) . $tBody;
// Send the Notification to the Server.
$tResult = fwrite ($tSocket, $tMsg, strlen ($tMsg));
if ($tResult)
echo 'Delivered Message to APNS' . PHP_EOL;
else
echo 'Could not Deliver Message to APNS' . PHP_EOL;
// Close the Connection to the Server.
fclose ($tSocket);发布于 2019-11-15 01:25:21
APNS令牌有两种不同的环境:沙盒和生产环境。它们需要完全独立的设置、权限、注册和推送设置。将沙盒APNS通知推送到生产令牌不起作用,生产APNS推送到沙盒令牌也是如此。
如果您已经在沙箱中进行了验证,但没有在生产中进行验证,那么您可能需要复制所有用于生产的权限和证书。还要仔细检查您的PHP代码推送到哪里,并确保它是正确的环境(Sandbox vs Prod)。
https://stackoverflow.com/questions/58857384
复制相似问题