Documentation
¶
Index ¶
Constants ¶
const ( PKBarcodeFormatQR BarcodeFormat = "PKBarcodeFormatQR" PKBarcodeFormatPDF417 = "PKBarcodeFormatPDF417" PKBarcodeFormatAztec = "PKBarcodeFormatAztec" )
Supported Barcode formats.
const ( PKDataDetectorTypePhoneNumber DataDetector = "PKDataDetectorTypePhoneNumber" PKDataDetectorTypeLink = "PKDataDetectorTypeLink" PKDataDetectorTypeAddress = "PKDataDetectorTypeAddress" PKDataDetectorTypeCalendarEvent = "PKDataDetectorTypeCalendarEvent" )
const ( PKTextAlignmentNatural TextAlignment = "PKTextAlignmentNatural" PKTextAlignmentLeft = "PKTextAlignmentLeft" PKTextAlignmentCenter = "PKTextAlignmentCenter" PKTextAlignmentRight = "PKTextAlignmentRight" )
const ( PKDateStyleNone DateTimeStyle = "PKDateStyleNone" PKDateStyleShort = "PKDateStyleShort" PKDateStyleMedium = "PKDateStyleMedium" PKDateStyleLong = "PKDateStyleLong" PKDateStyleFull = "PKDateStyleFull" )
const ( PKTransitTypeAir TransitType = "PKTransitTypeAir" PKTransitTypeBoat = "PKTransitTypeBoat" PKTransitTypeBus = "PKTransitTypeBus" PKTransitTypeGeneric = "PKTransitTypeGeneric" PKTransitTypeTrain = "PKTransitTypeTrain" )
Supported types of transit
const ( PKNumberStyleDecimal NumberStyle = "PKNumberStyleDecimal" PKNumberStylePercent = "PKNumberStylePercent" PKNumberStyleScientific = "PKNumberStyleScientific" PKNumberStyleSpellOut = "PKNumberStyleSpellOut" )
Variables ¶
var ErrNoPass = errors.New("pass.json missed") // the description of pass.json was not added to the file
Functions ¶
This section is empty.
Types ¶
type Barcode ¶
type Barcode struct { Format BarcodeFormat `json:"format"` // Barcode format. Message string `json:"message"` // Message or payload to be displayed as a barcode. MessageEncoding string `json:"messageEncoding"` // Textencodingthatisusedtoconvertthemessage from the string representation to a data representation to render the barcode. AltText string `json:"altText,omitempty"` // Text displayed near the barcode. For example, a human-readable version of the barcode data in case the barcode doesn’t scan. }
Barcode Dictionary: Information about a pass’s barcode.
type Beacon ¶
type Beacon struct { ProximityUUID string `json:"proximityUUID"` // Unique identifier of a Bluetooth Low Energy location beacon. Major uint16 `json:"major,omitempty"` // Major identifier of a Bluetooth Low Energy location beacon. Minor uint16 `json:"minor,omitempty"` // Minor identifier of a Bluetooth Low Energy location beacon. RelevantText string `json:"relevantText,omitempty"` // Text displayed on the lock screen when the pass is currently relevant. }
Beacon Dictionary: Information about a location beacon. Available in iOS 7.0.
type DataDetector ¶
type DataDetector string
type DateTimeStyle ¶
type DateTimeStyle string
type Field ¶
type Field struct { Key string `json:"key"` // The key must be unique within the scope of the entire pass. Label string `json:"label,omitempty"` // Label text for the field. Value interface{} `json:"value"` // Value of the field. AttributedValue string `json:"attributedValue,omitempty"` // Attributed value of the field. TextAlignment TextAlignment `json:"textAlignment,omitempty"` // Alignment for the field’s contents. ChangeMessage string `json:"changeMessage,omitempty"` // Format string for the alert text that is displayed when the pass is updated. The format string must contain the escape %@, which is replaced with the field’s new value. For example, “Gate changed to %@.” // DataDetectorTypes []DataDetector `json:"dataDetectorTypes,omitempty` // Data dectors that are applied to the field’s value. // Date Style Keys: Information about how a date should be displayed in a field. // If any of these keys is present, the value of the field is treated as a date. Either specify both a date style and a time style, or neither. DateStyle DateTimeStyle `json:"dateStyle,omitempty"` // Style of date to display. TimeStyle DateTimeStyle `json:"timeStyle,omitempty"` // Style of time to display. IgnoresTimeZone bool `json:"ignoresTimeZone,omitempty"` // Always display the time and date in the given time zone, not in the user’s current time zone. IsRelative bool `json:"isRelative,omitempty"` // If true, the label’s value is displayed as a relative date; otherwise, it is displayed as an absolute date. // Number Style Keys: Information about how a number should be displayed in a field. // These keys are optional if the field’s value is a number; otherwise they are not allowed. Only one of these keys is allowed per field. CurrencyCode string `json:"currencyCode,omitempty"` // ISO 4217 currency code for the field’s value. NumberStyle NumberStyle `json:"numberStyle,omitempty"` // Style of number to display. }
Standard Field Dictionary Keys: Information about a field. These keys are used for all dictionaries that define a field.
type Fields ¶
type Fields struct { TransitType TransitType `json:"transitType,omitempty"` // Type of transit. Required for boarding passes; otherwise not allowed. Primary FieldsData `json:"primaryFields,omitempty"` // Fields to be displayed prominently on the front of the pass. Secondary FieldsData `json:"secondaryFields,omitempty"` // Fields to be displayed on the front of the pass. Auxiliary FieldsData `json:"auxiliaryFields,omitempty"` // Additional fields to be displayed on the front of the pass. Back FieldsData `json:"backFields,omitempty"` // Fields to be on the back of the pass. Header FieldsData `json:"headerFields,omitempty"` // Fields to be displayed in the header on the front of the pass. }
Fields Pass Structure Dictionary: Keys that define the structure of the pass. These keys are used for all pass styles and partition the fields into the various parts of the pass.
type Location ¶
type Location struct { Latitude float64 `json:"latitude"` // Latitude, in degrees, of the location. Longitude float64 `json:"longitude"` // Longitude, in degrees, of the location. Altitude float64 `json:"altitude,omitempty"` // Altitude, in meters, of the location. RelevantText string `json:"relevantText,omitempty"` // Text displayed on the lock screen when the pass is currently relevant. }
Location Dictionary: Information about a location.
type NumberStyle ¶
type NumberStyle string
type Pass ¶
type Pass struct { // Standard Keys: Information that is required for all passes. FormatVersion int `json:"formatVersion"` // Version of the file format. The value must be 1. PassTypeIdentifier string `json:"passTypeIdentifier"` // Pass type identifier, as issued by Apple. The value must correspond with your signing certificate. SerialNumber string `json:"serialNumber"` // Serial number that uniquely identifies the pass. No two passes with the same pass type identifier may have the same serial number. TeamIdentifier string `json:"teamIdentifier"` // Team identifier of the organization that originated and signed the pass, as issued by Apple. OrganizationName string `json:"organizationName"` // Display name of the organization that originated and signed the pass. Description string `json:"description"` // Brief description of the pass, used by the iOS accessibility technologies. // Associated App Keys: Information about an app that is associated with a pass. AppLaunchURL string `json:"appLaunchURL,omitempty"` // A URL to be passed to the associated app when launching it. AssociatedStoreIdentifiers []int `json:"associatedStoreIdentifiers,omitempty"` // A list of iTunes Store item identifiers for the associated apps. // Companion App Keys: Custom information about a pass provided for a companion app to use. UserInfo map[string]interface{} `json:"userInfo,omitempty"` // Custom information for companion apps. This data is not displayed to the user. // Expiration Keys: Information about when a pass expires and whether it is still valid. // A pass is marked as expired if the current date is after the pass’s expiration date, or if the pass has been explicitly marked as voided. ExpirationDate *W3Time `json:"expirationDate,omitempty"` // Date and time when the pass expires. Voided bool `json:"voided,omitempty"` // Indicates that the pass is void—for example, a one time use coupon that has been redeemed. // Relevance Keys: Information about where and when a pass is relevant. Beacons []Beacon `json:"beacons,omitempty"` // Beacons marking locations where the pass is relevant. Locations []Location `json:"locations,omitempty"` // Locations where the pass is relevant. MaxDistance uint `json:"maxDistance,omitempty"` // Maximum distance in meters from a relevant latitude and longitude that the pass is relevant. RelevantDate *W3Time `json:"relevantDate,omitempty"` // Date and time when the pass becomes relevant. // Visual Appearance Keys: Visual styling and appearance of the pass. Barcode *Barcode `json:"barcode,omitempty"` // Information specific to barcodes. BackgroundColor *Color `json:"backgroundColor,omitempty"` // Background color of the pass, specified as an CSS-style RGB triple. ForegroundColor *Color `json:"foregroundColor,omitempty"` // Foreground color of the pass, specified as a CSS-style RGB triple. LabelColor *Color `json:"labelColor,omitempty"` // Color of the label text, specified as a CSS-style RGB triple. LogoText string `json:"logoText,omitempty"` // Text displayed next to the logo on the pass. GroupingIdentifier string `json:"groupingIdentifier,omitempty"` // Optional for event tickets and boarding passes; otherwise not allowed. Identifier used to group related passes. If a grouping identifier is specified, passes with the same style, pass type identifier, and grouping identifier are displayed as a group. Otherwise, passes are grouped automatically. // Style Keys: Specifies the pass style. // Provide exactly one key—the key that corresponds with the pass’s type. Generic *Fields `json:"generic,omitempty"` // Information specific to a generic pass. BoardingPass *Fields `json:"boardingPass,omitempty"` // Information specific to a boarding pass. Coupon *Fields `json:"coupon,omitempty"` // Information specific to a coupon. EventTicket *Fields `json:"eventTicket,omitempty"` // Information specific to an event ticket. StoreCard *Fields `json:"storeCard,omitempty"` // Information specific to a store card. // Web Service Keys: Information used to update passes using the web service. AuthenticationToken string `json:"authenticationToken,omitempty"` // The authentication token to use with the web service. The token must be 16 characters or longer. WebServiceURL string `json:"webServiceURL,omitempty"` // The URL of a web service that conforms to the API described in Passbook Web Service Reference. }
type TextAlignment ¶
type TextAlignment string
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer allows you to write files in Apple Passbook format.
func NewWriter ¶
func NewWriter(out io.Writer, cert *x509.Certificate, priv *rsa.PrivateKey) *Writer
NewWriter creates a new Writer that allows you to create an Apple Passbook file. As parameters, a stream is passed to which the given file will be written, as well as the certificates that will be used to create the digital signature.
func (*Writer) Add ¶
Add adds a new file to the Passbook. Only files with the extension .png and .strings are added. Plus, a file called pass.json is added, which is a direct description. All other files are ignored.
func (*Writer) Close ¶
Close finishes writing an Apple Passbook file and adds it automatically generated manifest and signature file. At the time of creating a digital signature, error, which in this case will also be returned. In addition, the error will return if the description of pass.json was not added to the file.