1

When I add a pass in a device, I see on the console like this:

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

..... Why it tries to register to com.apple.PassKit ? In my server, I use some codes in index.php like the following:

<?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;
}

?>
PassKit
  • 12,231
  • 5
  • 57
  • 75
malinchhan
  • 767
  • 2
  • 8
  • 28
  • In my pass.json: "webServiceURL" : "https://192.168.1.202/passesWebserver", "authenticationToken" : "Fy7Iiew81JNdsdaG", .......... – malinchhan Mar 26 '13 at 07:54

1 Answers1

2

This is what a successful registration looks like in the console:

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

What you have posted above is only the last line of this process, (where passd has picked up that you have more than 10 locations in your pass.json).


If you examine the above you can see the flow of events that your web service needs to respond to:

Row 1: Device sends a POST request to:

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

Row 2: POST request is sent with the header field:

Authorization: ApplePass {authenticationToken}

Row 3: POST body contains the JSON Dictionary:

{
    pushToken = {pushToken};
}

Provided your rewrite rule is correct, your PHP code should analyse the URL and capture the deviceLibraryIdentifier and pushToken and store it in the database, linked to the pass record containing the serialNumber, authenticationToken and passTypeIdentifier.

Then Row 4: Your web service responds to the device with a 201 code to indicate that the registration was successful.

On Row 5: The device then generates a GET request to your web service to check if there is a newer versions pof passes for the same certificate:

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

On Row 6, 7 and 8: The device generates a GET request to your web service to check if there is a newer version of this specific pass. It provides an If-Modified-Since header containing the date provided in the header of the last downloaded .pkpass bundle (Row 7), and provides another Authorization header containing Applepass {authenticationToken} (Row 8) so that your web service can validate the request against by checking the database record for the serialNumber.

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

On Row 9: the web service responds with a 204 response, indicating that there are no serialNumbers for the passTypeIdentifier that require updating. Row 10 confirms this.

Finally, on Row 11, the device receives a 304 response from your web service, confirming that the pass it has just installed is the latest version of the pass.

The above outlines precisely what your web service will receive and the responses it needs to provide to successfully register a device.

PassKit
  • 12,231
  • 5
  • 57
  • 75
  • Yes! Your index.php should contain the code [from here](http://stackoverflow.com/questions/15469533/how-to-set-webserviceurl-and-register-successfully) – PassKit Mar 27 '13 at 06:50
  • I still cannot see the result on console even now rewrite rule works ! – malinchhan Mar 29 '13 at 03:42
  • Good that the rewrite rule is working. Toggle notifications on and off on the back of the pass while connected to Xcode. What do you see in the console? – PassKit Mar 29 '13 at 04:22
  • when I add pass by app or web server ? – malinchhan Mar 29 '13 at 04:28
  • Doesn't matter how the pass is added, as long as it contains the `webServiceURL` and `authenticationToken`. When you toggle notifications on the back of the pass, the device will try to register again with your web service and you should get some clues as to what is happening. Also check your PHP logs to see if your script is failing because of an error. – PassKit Mar 29 '13 at 04:30
  • in console, when I change on to off for Automatic updates, I see these: 'Mar 29 11:32:52 CamMobs-iPod4 UserEventAgent[13] : Could not get event name for stream/token: com.apple.backgroundtaskagent/5453: 0x3: No such process Mar 29 11:32:52 CamMobs-iPod4 UserEventAgent[13] : Could not look up channel/token: com.apple.backgroundtaskagent/0x5453: 0x3: No such process – malinchhan Mar 29 '13 at 04:37
  • Mar 29 11:33:00 CamMobs-iPod4 profiled[9899] : (Note ) profiled: Idled. Mar 29 11:33:00 CamMobs-iPod4 profiled[9899] : (Note ) profiled: Service stopping. – malinchhan Mar 29 '13 at 04:38
  • You are posting the wrong part of the console logs. The part that you need should contain have `passd` E.g. `Mar 29 11:33:00 CamMobs-iPod4 passd[`. Make sure that in your device you have turned on extended logging for passbook. – PassKit Mar 29 '13 at 04:42
  • when I add a pass again , i see these : Mar 29 11:44:45 CamMobs-iPod4 backboardd[52] : Application 'UIKitApplication:com.cam-mob.PassbookPassTest[0xc384]' exited abnormally with signal 9: Killed: 9 – malinchhan Mar 29 '13 at 04:48
  • Does the pass add to the device or not? – PassKit Mar 29 '13 at 04:52
  • So do you have a notifications toggle on the back? Have you enabled PassKit Additional Logging and do you see a registration attempt in the console? – PassKit Mar 29 '13 at 04:55
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/27143/discussion-between-passkit-and-smallgirl) – PassKit Mar 29 '13 at 04:56
  • How to set number 7 and also 11 ? – malinchhan Apr 08 '13 at 04:51
  • 7. Mar 26 17:00:04 iPhone5 passd[6262] : Request contains header field ? – malinchhan Apr 08 '13 at 04:51
  • before, I use $authKey for getting from "Header: Authorization: ApplePass {authenticationToken}". what about "Header: If-Modified-Since: {last modified date}" ? what will I get from this ? – malinchhan Apr 08 '13 at 04:55
  • The value will be in `$_SERVER['HTTP-IF-MODIFIED-SINCE'];`. See the accepted answer to this question for more on how to use it http://stackoverflow.com/questions/10847157/handling-if-modified-since-header-in-a-php-script – PassKit Apr 08 '13 at 05:17
  • where should I put header of if-modified-since ? – malinchhan Apr 08 '13 at 05:46
  • I put this: if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($localFileName)) { header('HTTP/1.0 304 Not Modified'); exit; } – malinchhan Apr 08 '13 at 05:52
  • how to see it in console ? – malinchhan Apr 08 '13 at 05:53
  • It You should see something like `: 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` – PassKit Apr 08 '13 at 06:37
  • no, I get this : "[2013-04-08 13:46:12 +0700] Get pass task (pass type pass.cam-mob.passbookpasstest, serial number 0001, if-modified-since (null); with web service url http://192.168.1.202:8888/passesWebserver/) encountered error: Server response was malformed (Missing response data)" – malinchhan Apr 08 '13 at 07:00
  • This implies that your server is not sending the .pkpass bundle. Check PHP logs for clues! – PassKit Apr 08 '13 at 07:12
  • how to get s.th on console like you in 7. Mar 26 17:00:04 iPhone5 passd[6262] : Request contains header field ? – malinchhan Apr 08 '13 at 07:25
  • How do you view all messages in console without displaying on a dev device? – Michael Aug 30 '17 at 13:29