簡體   English   中英

“已向 APNS 傳遞消息”但未在使用 ios13 (PHP) 的生產中顯示通知

[英]“Delivered Message to APNS” but not showing notification in Production with ios13 (PHP)

我在 ios13 中的通知有問題。 如果我使用 gateway.sandbox,我可以看到通知,但我已經直接從 AppStore 下載了該應用程序。 而是使用 gateway.apple 我看到“已向 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);

APNS令牌有兩種不同的環境; 沙盒和生產。 它們需要完全獨立的設置、權限、注冊和推送設置。 將沙盒 APNS 通知推送到生產令牌將不起作用,與將生產 APNS 推送到沙盒令牌相同。

如果您已在 Sandbox 中驗證但未在生產中驗證,則可能需要復制所有權限和證書以進行生產。 還要使用 PHP 代碼仔細檢查您要推送到的位置,並確保它是正確的環境(沙盒與產品)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM