I create a pass dynamically. Each pass has some different contents such as primary field, secondary field, but all pass has same serial and passTypeID, so is it right to do like this ?
Yes, the serialNumber
and PassTypeIdentifier
can be the same, even if each pass has different contents. However, there are a couple of things to consider.
Passbook will only allow one Pass of with the same serialNumber
and passTypeIdentifier
combination at any one time. This means that if user A has a pass installed with a primaryField
key of name
containing a value of Malin
, then user A trys to install a second pass that contains a primaryField
key of name
containing a value of Nick
, then Passbook will treat this as an update of the orignal pass and will replace Marlin's
pass with Nick's
pass.
Using the same serialNumber
and PassTypeIdentifier
can have advantages in that it prevents users loading multiple copies of the same pass on a single device. But sometimes it may not be what you need (E.g. a parent wanting to hold both their own and their child's boarding passes).
If you use the same serialNumber, then you need to consider how you uniquely identify pass records in your database. You don't want a situation where crediting Malin's
pass with 1,000 points, also credit's everyone else's pass.
We use the authenticationToken
as a unique key because it is supplied in the 3 of the 4 pass related methods of the Passbook Web Service (Register, Unregister and Refresh). Unfortunately, it isn't provided in the Getting the Serial Numbers for Passes Associated with a Device
method, so we add the authenticationToken to the devices table to provide a common key so we can check the pass record to see if it has been updated.