1

当我在设备中添加通行证时,我在控制台上看到如下:

Mar 26 14:32:36 CamMobs-iPod4 passd[7128] <Warning>: Card has more than 10 locations. Capping.
Mar 26 14:32:38 CamMobs-iPod4 MobileSafari[7115] <Warning>: Warning: Attempt to dismiss from view controller <BrowserRootViewController: 0x1ed546a0> while a presentation or dismiss is in progress!
Mar 26 14:32:39 CamMobs-iPod4 backboardd[52] <Warning>: CoreAnimation: updates deferred for too long
Mar 26 14:32:39 CamMobs-iPod4 locationd[41] <Notice>: Location icon should now be in state 'Active'
Mar 26 14:32:50 CamMobs-iPod4 locationd[41] <Notice>: Location icon should now be in state 'Inactive'
Mar 26 14:32:52 CamMobs-iPod4 profiled[7122] <Notice>: (Note ) profiled: Idled.
Mar 26 14:32:52 CamMobs-iPod4 profiled[7122] <Notice>: (Note ) profiled: Service stopping.
Mar 26 14:33:31 CamMobs-iPod4 locationd[41] <Warning>: Launch Services: Registering unknown app identifier com.apple.PassKit failed
Mar 26 14:33:31 CamMobs-iPod4 locationd[41] <Warning>: Launch Services: Unable to find app identifier com.apple.PassKit
Mar 26 14:33:33 CamMobs-iPod4 configd[50] <Notice>: network changed: v4(en0:192.168.1.109) DNS Proxy
Mar 26 14:33:53 CamMobs-iPod4 backboardd[52] <Notice>: Posting 'com.apple.iokit.hid.displayStatus' notifyState=0

.....为什么它试图注册到 com.apple.PassKit ?在我的服务器中,我在 index.php 中使用了一些代码,如下所示:

<?php
    // Transfer Request URL into array
$request = explode("/", substr(@$_SERVER['REQUEST_URI'], 1));
//$request = explode("/", substr(@$_SERVER['REQUEST_URI'], 1));
print_r($_SERVER['REQUEST_URI']);

if (strtoupper($_SERVER['REQUEST_METHOD']) === "POST"
    && isset($_SERVER['HTTP_AUTHORIZATION'])
    && strpos($_SERVER['HTTP_AUTHORIZATION'], 'ApplePass') === 0
    && $request[2] === "devices"
    && $request[4] === "registrations") {

$auth_key = str_replace('ApplePass ', '', $_SERVER['HTTP_AUTHORIZATION']);

$device_id = $request[3];
$pass_id = $request[5];
$serial = $request[6];

echo $request[3];
//$device_id = $_POST[''];
echo $device_id;
echo $pass_id;
echo $serial ; 
// Catch the JSON post and decode it
$dt = @file_get_contents('php://input');
   // $dt = @file_get_contents('php://input');
//$device_token = json_decode($dt);
//$device_token = $device_token->pushToken;

$pushtoken=json_decode($dt)->pushToken;
if (!$device_token) die('No Token Found'); // Token wasn't found

    $dbhost = 'localhost:8889';
    $dbuser = 'root';
    $dbpass = 'root';
    $dbname = 'passesdb';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass)

    or die ('Error connecting to mysql'.mysql_error());         

    mysql_select_db($dbname);
    mysql_query("SET NAMES UTF8");
    mysql_query($sql,$conn);
    $table = 'Devices';
    $sql = mysql_query("insert into Devices values('$device_id','$pushtoken')");
    mysql_query($sql);
exit;
}

?>
4

1 回答 1

2

这是在控制台中成功注册的样子:

1. Mar 26 17:00:03 iPhone5 passd[6262] <Warning>: Generating POST request with URL <https:/afr.passk.it/v1/devices/7864dc8fdcfe739273cf7362a0db2b35/registrations/pass.it.passk.developer3/1wqdDAqHydkRURA9YCjbq>
2. Mar 26 17:00:03 iPhone5 passd[6262] <Warning>: Request contains header field <Authorization: ApplePass 5cdddad65324384efa39575a4cf22424>
3. Mar 26 17:00:03 iPhone5 passd[6262] <Warning>: Request contains body dictionary {
        pushToken = 0bbe54794500332b789a3ddb69827386d5c9aad1cb035c9f2725761d419950b2;
    }
4. Mar 26 17:00:04 iPhone5 passd[6262] <Warning>: Register task (for device 7864dc8fdcfe739273cf7362a0db2b35, pass type pass.it.passk.developer3, serial number 1wqdDAqHydkRURA9YCjbq; with web service url https://afr.passk.it/) got response with code 201
5. Mar 26 17:00:04 iPhone5 passd[6262] <Warning>: Generating GET request with URL <https:/afr.passk.it/v1/devices/7864dc8fdcfe739273cf7362a0db2b35/registrations/pass.it.passk.developer3?passesUpdatedSince=1364287618>
6. Mar 26 17:00:04 iPhone5 passd[6262] <Warning>: Generating GET request with URL <https:/afr.passk.it/v1/passes/pass.it.passk.developer3/1wqdDAqHydkRURA9YCjbq>
7. Mar 26 17:00:04 iPhone5 passd[6262] <Warning>: Request contains header field <If-Modified-Since: Tue, 26 Mar 2013 07:35:33 GMT>
8. Mar 26 17:00:04 iPhone5 passd[6262] <Warning>: Request contains header field <Authorization: ApplePass 5cdddad65324384efa39575a4cf22424>
9. Mar 26 17:00:04 iPhone5 passd[6262] <Warning>: Get serial #s task (for device 7864dc8fdcfe739273cf7362a0db2b35, pass type pass.it.passk.developer3, last updated 1364287618; with web service url https://afr.passk.it/) got response with code 204
10. Mar 26 17:00:04 iPhone5 passd[6262] <Warning>: Get serial numbers task completed with update tag (null), serial numbers (null)
11. Mar 26 17:00:05 iPhone5 passd[6262] <Warning>: Get pass task (pass type pass.it.passk.developer3, serial number 1wqdDAqHydkRURA9YCjbq, if-modified-since Tue, 26 Mar 2013 07:35:33 GMT; with web service url https://afr.passk.it/) got response with code 304

您在上面发布的内容只是此过程的最后一行,(在哪里passd发现您的 pass.json 中有 10 多个位置)。


如果您检查上述内容,您可以看到您的 Web 服务需要响应的事件流:

第 1 行:设备将 POST 请求发送到:

https://webserviceURL/v1/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}/{serialNumber}`

第 2 行: POST 请求使用头字段发送:

Authorization: ApplePass {authenticationToken}

第 3 行: POST 正文包含 JSON 字典:

{
    pushToken = {pushToken};
}

如果您的重写规则是正确的,您的 PHP 代码应该分析 URL 并捕获deviceLibraryIdentifierandpushToken并将其存储在数据库中,链接到包含serialNumber,authenticationTokenpassTypeIdentifier.

然后第 4 行:您的 Web 服务使用代码响应设备,201表明注册成功。

第 5 行:设备然后向您的 Web 服务生成一个 GET 请求,以检查是否有更新版本的 pof 通过相同的证书:

https:/webserviceURL/v1/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}?passesUpdatedSince={lastUpdateTag}

第 6、7 和 8 行:设备向您的 Web 服务生成 GET 请求,以检查是否有此特定通行证的更新版本。它提供了一个If-Modified-Since header包含上次下载的 .pkpass 包(第 7 行)的标题中提供的日期,并提供了另一个Authorization包含Applepass {authenticationToken}第 8 行)的标题,以便您的 Web 服务可以通过检查数据库记录来验证请求serialNumber

https:/webserviceURL/v1/passes/{passTypeIdentifier}/{serialNumber}
Header: If-Modified-Since: {last modified date}
Header: Authorization: ApplePass {authenticationToken}

第 9 行: Web 服务以204响应响应,指示没有需要更新 serialNumber的 s 。第 10 行证实了这一点。passTypeIdentifier

最后,在第 11 行,设备收到304来自您的 Web 服务的响应,确认它刚刚安装的通行证是该通行证的最新版本。

上面准确地概述了您的 Web 服务将接收的内容以及成功注册设备所需的响应。

于 2013-03-26T09:34:17.320 回答