简体   繁体   English

苹果钱包未将推送令牌提供给Web服务

[英]Apple Wallet not giving Push Token to Web Service

I have a Pass for Apple Wallet with a webServiceURL specified which I am currently trying to get working. 我有一个Apple电子钱包通行证,其中指定了一个webServiceURL ,我目前正在尝试使用。 So far, I can tell if the pass is added or deleted, after verifying with Auth Token and I get the correct Device ID as well as Serial Numbers. 到目前为止,在通过Auth Token进行验证后,我可以确定该通行证是添加还是删除,并且可以获得正确的设备ID和序列号。 However, the value of $_POST is an empty array when the pass is added, so I cannot get the Push Token. 但是,添加通行证时, $_POST _ $_POST的值是一个空数组,因此我无法获得推送令牌。 Is there something I am missing? 我有什么想念的吗? Here is my PHP. 这是我的PHP。

<?php
function unauthorized() {
  header('HTTP/1.1 401 Unauthorized');
  exit;
}
$headers = apache_request_headers();
if (isset($headers['Authorization']) && strpos($headers['Authorization'], 'ApplePass') === 0 && strpos($_SERVER['PATH_INFO']) !== false) {
  $pathInfo = $_SERVER['PATH_INFO'];
  if ($pathInfo[0] === '/') { $pathInfo = substr($pathInfo, 1); }
  $parameters = explode('/', $pathInfo);
  if ($parameters[0] !== 'v1' || $parameters[1] !== 'devices' || $parameters[3] !== 'registrations' || $parameters[4] !== 'MYPASSIDENTIFIER') {
    unauthorzed();
    exit;
  }

  $deviceId = $parameters[2];
  $passSerial = $parameters[5];

  if ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
    // User deleted pass

  } else  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // User added pass
    $payload = json_decode($_POST);
    // $_POST is empty array, and $payload is always nothing
  } else {
    // Something fishy
    unauthorized();
  }

} else {
  unauthorized();
}

Try using the REQUEST_URI and read the body with php://inpupt 尝试使用REQUEST_URI并使用php://inpupt阅读正文

$headers = apache_request_headers();
$request = explode("/", substr(@$_SERVER['REQUEST_URI'], 1));

if (strtoupper($_SERVER['REQUEST_METHOD']) === "POST" 
    && isset($headers['Authorization'])
    && (strpos($headers['Authorization'], 'ApplePass') === 0)
    && $request[1] === "devices"
    && ($request[3] === "registrations") {

    $auth_key = str_replace(array('ApplePass '), '', $headers['Authorization']);

    $device_id = $request[2];
    $pass_id = $request[4];
    $serial = $request[5];

    $dt = @file_get_contents('php://input');
    $det = json_decode($dt);

    // Process Device Token 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM