0

I created a pass and can register device to my server. I also updated this pass by changing some contents and insert a new row of pass to pass table. But why in console, last updated (null) ? this is what I get from console:
Apr 6 10:30:29 CamMobs-iPod4 passd[21] <Warning>: Get serial #s task (for device b6511c0dd47d04da449ce427b27fea74, pass type pass.cam-mob.passbookpasstest, last updated (null); with web service url http://192.168.1.202:8888/passesWebserver/) got response with code 200

malinchhan
  • 767
  • 2
  • 8
  • 28

1 Answers1

1

Whenever a .pkpass bundle is accepted or replaced in a device's Passbook library, Passbook will tag the pass with a last updated attribute.

This attribute is typically set by the Last-Modified header a webserver sends the first time the pass is downloaded, and your web service sends with every response to the "Get Latest Version of a Pass" response.

Passbook also polls your web service using a "Getting the Serial Numbers for Passes Associated with a Device" method for serialNumbers, using the deviceLibraryIdentifier and passTypeIdentifier as criteria.

The "Getting the Serial Numbers for Passes Associated with a Device" response should contain a tag lastUpdated, indicating when the results of this query were last changed (I.e. when was the last time that a pass using the passTypeIdentifier registered to this deviceLibraryIdentifier was last updated).

However, the very first time Passbook sends a "Getting the Serial Numbers for Passes Associated with a Device", it will not have received a lastUpdated tag which is why it is showing null in your console log. Also, sending a lastUpdated tag is optional, so if it is not present, or if it is not sent correctly, then you will always see last updated (null) for this request.

You are free to use whatever you like as a lastUpdated tag. The simplest solution to implement is a unix timestamp as there is no need to mess around with date formats.

PassKit
  • 12,231
  • 5
  • 57
  • 75
  • So I need to make response for 'Getting the Serial Numbers for Passes Associated with a Device'and 'Getting the Latest Version of a Pass' before Opening a connection to the Apple Push Notification Service (APNS) ? – malinchhan Apr 08 '13 at 01:39
  • Yes - you need to implement every method of the web service. You can test the 'Getting the Latest version of a Pass' method by flipping the pass over and pulling down on the back to manually trigger a refresh – PassKit Apr 08 '13 at 03:18
  • for getting the Serial Numbers for Passes Associated with a Device, I use this header: header('Last-Modified: ' . date("D, d M Y H:i:s", filemtime('/Applications/MAMP/htdocs/passesWebserver/DigiClubCard.pkpass')) . ' GMT+07:00'); why last updated is still null ? – malinchhan Apr 08 '13 at 03:23
  • The lastUpdated tag is set by the lastUpdated tag that you sent in the last JSON response to the "Getting the Serial Numbers for Passes Associated with a Device" request. If you have never sent a valid response to this method then lastUpdated will always be null. Passbook does not use the `LAst-Modified` header for this call - if only uses it when you are sending .pkpass files. – PassKit Apr 08 '13 at 03:31
  • how to send .pkpass file to device ? – malinchhan Apr 08 '13 at 03:42
  • When - initially, or in response to the "Getting the Serial Numbers for Passes Associated with a Device" method? The answer in both cases is to set a header and then server the .pkpass bundle, which was answered here http://stackoverflow.com/questions/15383552/how-to-set-mime-type-of-application-vnd-apple-pkpass-in-order-to-share-pass-by-l – PassKit Apr 08 '13 at 03:58
  • now I get 'Apr 8 10:59:03 CamMobs-iPod4 passd[21] : Get serial numbers task completed with update tag 1365393543, serial numbers ( 0001 ) ' – malinchhan Apr 08 '13 at 04:02
  • I have response in getting the Serial Numbers for Passes Associated with a Device, but no response yet in getting the Latest Version of a Pass ! – malinchhan Apr 08 '13 at 04:03
  • Great! That is exactly what you want to see. When the device next calls that method (most likely in response to a push request), you will see the lastUpdated tag 1365393543 – PassKit Apr 08 '13 at 04:03
  • yes ! In pass table, I insert new row of pass and I only change 1 content and UpdateTag. What I need to do next is response for getting the latest version of pass ! – malinchhan Apr 08 '13 at 04:07
  • so I need to add : header('Content-Type: application/vnd.apple.pkpass'); and how can I send newUpdated .pkpass to device ? – malinchhan Apr 08 '13 at 04:10
  • so I need to use this : – malinchhan Apr 08 '13 at 04:12
  • $filesize = filesize($pkpass_file); if ($filesize) header("Content-Length: ". $filesize); header('Content-Transfer-Encoding: binary'); if (filemtime($pkpass_file)) { date_default_timezone_set("UTC"); header('Last-Modified: ' . date("D, d M Y H:i:s", filemtime($pkpass_file)) . ' GMT'); } flush(); readfile($pkpass_file); – malinchhan Apr 08 '13 at 04:13
  • can the old pass updates automatically or need a push notification ? – malinchhan Apr 08 '13 at 04:30
  • It needs a push notification - otherwise, how will it know that it needs to update? The user can also manually update it by flipping the pass and pulling down. – PassKit Apr 08 '13 at 05:19
  • So now it's time for me to connect to APNS ! – malinchhan Apr 08 '13 at 05:41