23.0. Introduction(Pass Kit)
优惠券,车票,船票等
蓝图:
23.1. Creating Pass Kit Certificates
创建证书
1,找到iOS 开发中心
2,登陆
3,选择Certificates, Identifiers & Profiles
4,Identifier->Pass Type IDs
5,点击(+)按钮
6,Description编辑框中输入描述
7,Identifier 的ID框中,输入pass ID(域名反转格式),比如App ID是com.pixolity.testingpasskit ,那么这里可以是pass.pixolity.ios.cookbook.testingpasses.必须以pass开头,后面的不定。
continue -> register-> done
接下来就是创建关联Pass Type ID 的证书
1,Pass Type IDs->刚才创建的ID->setting(Edit now)
2,这时会看见create certificate 按钮,点它
3,创建证书界面
4,continue之后
5,choose file之前你需要先到钥匙串应用那边 钥匙串访问->证书助理->从证书颁发机构请求证书 生成个证书请求文件,然后这里选择那个文件。
6,下载证书并安装。在钥匙串【登陆】【我的证书】中可以看到刚安装的证书,专用密钥要妥善保存,当你换电脑时可以用上。
23.2. Creating Pass Files
创建pass.json文件
1,Xcode里面file->New->Project...
2,iOS类别下->Other->Empty->Next
3,输入Product Name后next,保存
4,file->New->File...
5,iOS类别下->Other->Empty->Next
6,保存成 pass.json
接下来我们先看一个简单的pass file
{
"formatVersion": 1,
"passTypeIdentifier": "<# Put your Pass Type ID here #>",
"serialNumber": "p69f2J",
"teamIdentifier": "<# Put your team ID here #>",
"description": "Train Ticket Example",
"locations": [
{
"longitude": -0.170867,
"latitude": 50.834948
}
],
"barcode": {
"message": "1234567890",
"format": "PKBarcodeFormatPDF417",
"messageEncoding": "iso-8859-1"
},
"organizationName": "O'Reilly Railways",
"logoText": "O'Reilly Railways",
"foregroundColor": "rgb(255, 255, 255)",
"backgroundColor": "rgb(100, 100, 100)",
"boardingPass": {
"transitType": "PKTransitTypeTrain",
"primaryFields": [
{
"key": "departure",
"label": "Departs From",
"value": "Hove, 07:37"
},
{
"key": "departurePlatform",
"label": "Departs from Platform",
"value": "2"
}
],
"auxiliaryFields": [
{
"key": "arrival",
"label": "Arrives At",