What are the possible reasons to get APNs responses BadDeviceToken or Unregistered?

前端 未结 6 1571
离开以前
离开以前 2021-02-01 14:38

When sending notifications to iOS users, for some of them I get response status code 400 (BadDeviceToken) or code 410 (Unregistered).

From Apple documentation about \"Ba

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 15:14

    Error code 404: BadDevice token

    Posssible reasons:

    1. Your .pem certificate may be wrong.
    2. Your BundleId may be wrong.
    3. Your Device id may be wrong.

    Note: Append .voip with your bundleid for sending voip push notification(exmple: bundleid.voip)

    Here is an workable example of voip push notification :

     $url,
            CURLOPT_PORT => 443,
            CURLOPT_HTTPHEADER => $headers,
            CURLOPT_POST => TRUE,
            CURLOPT_POSTFIELDS => $message,
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSLCERT => $cert,
            CURLOPT_HEADER => 1
        ));
        $result = curl_exec($http2ch);
        if ($result === FALSE) {
          throw new Exception("Curl failed: " .  curl_error($http2ch));
        }
        // get response
        $status = curl_getinfo($http2ch, CURLINFO_HTTP_CODE);
        if($status=="200")
        echo "SENT|NA";
        else
        echo "FAILED|$status";
    }
    ?> 
    

提交回复
热议问题