Уведомление Apple Push не получено

Я использую следующий скрипт PHP для APNS

function send_push_ios_test($msg)
    {
        // Put your device token here (without spaces):
        $deviceToken = '6778601ee2fd7809a90f2eaf709d5bbbbd3bec38c5b35e1428d7857f4b6ec0a7';
        //$deviceToken = '6778601e e2fd7809 a90f2eaf 709d5bbb bd3bec38 c5b35e14 28d7857f 4b6ec0a7';

        // Put your private key's passphrase here:
        $passphrase = 'Pass@123';
        // Put your alert message here:
        $message = $msg;
        ////////////////////////////////////////////////////////////////////////////////
        $ctx = stream_context_create();
        stream_context_set_option($ctx, 'ssl', 'local_cert', '../uploads/ios_pns/ck.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);
        $fp = stream_socket_client('ssl://gateway.sandbox.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' => array(
                    'body' => $message,
                'action-loc-key' => 'Bango App',
                     ),
                    'badge' => 2,
                'sound' => 'oven.caf',
                );

        // 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 'Message not delivered' . PHP_EOL;
        else
            echo 'Message successfully delivered' . PHP_EOL;
        // Close the connection to the server
        fclose($fp);
    } 

Сценарий показывает подключение к APNS, а затем сообщение успешно доставлено, но я не получаю push-сообщение на моем устройстве. Кто-нибудь может мне помочь с этим. Push-уведомление включено на моем устройстве для примера приложения, а также из XCODE.

0 ответов

Другие вопросы по тегам