我已经向 App Store 提交了一个应用程序。我用我的设备生成了一个令牌并使用以下 PHP-Scritp 发送它:
$deviceToken = 'b6e03b75f73bb9133c34434a09390e29g12696e8f32b3d29d1dd97a7e0a9adbd';
// Put your private key's passphrase here:
$passphrase = 'Passwort';
// Put your alert message here:
$message = $titel;
////////////////////////////////////////////////////////////////////////////////
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'Zertifikate.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$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);
echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default',
'badge' => '+1'
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$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)
echo 'Nachricht wurde nicht zugestellt' . PHP_EOL;
else
echo 'PUSHH!!' . PHP_EOL;
// Close the connection to the server
fclose($fp);
它说它已连接到 APNS,结果是肯定的。我不知道我应该怎么做。我只是在生产中使用与开发中相同的代码,但我将数据发送到 gateway.push.apple.com-Server。