@1amageek/passkit 中文文档教程

发布于 4年前 浏览 36 项目主页 更新于 3年前

passkit.ts

passkit.ts 是一个使用 typescript 发布通行证的库。

Installation

npm add @1amageek/passkit

Usage

const options: PassKit.Options = {
    secretURL: "SECRET_URL", // 
    wwdrURL: "WWDR_URL",
    passTypeIdentifier: "pass.**.**.**",
    teamIdentifier: "TEAM_ID",
    password: "PASSWORD",
}

PassKit.initialize(options)
const assets = new PassKit.Assets()
assets.icon = "URL_icon"
assets.icon2x = "URL_icon2x"
assets.logo = "URL_logo"
assets.logo2x = "URL_logo2x"

const pass: PassKit.Pass = {}
pass.primaryFields = [
    {
        "key": "event",
        "label": "hoge",
        "value": "fuga"
    }
]
pass.secondaryFields = [
    {
        "key": "loc",
        "label": "hoge",
        "value": "fuga"
    }
]

const barcode: PassKit.Barcode = {
    altText: "wow",
    format: PassKit.BarcodeFormat.QR,
    message: "http://google.com",
    messageEncoding: "iso-8859-1"
}

const ticket: PassKit.EventTicket = new PassKit.EventTicket(pass, "Organization", "Description", "UUID_string")
ticket.webServiceURL = "https://google.com"
ticket.barcode = barcode
ticket.relevantDate = new Date()
ticket.logoText = "logo_string"
ticket.foregroundColor = new PassKit.RGB(255, 255, 255)
ticket.backgroundColor = new PassKit.RGB(255, 255, 255)
ticket.authenticationToken = "authenticationToken_string"
try {
    const path = await PassKit.generate(ticket, assets)
    console.log(path)
} catch (error) {
    console.log(error)
}

捐赠

passkit.ts

passkit.ts is a library for issuing pass with typescript.

Installation

npm add @1amageek/passkit

Usage

const options: PassKit.Options = {
    secretURL: "SECRET_URL", // 
    wwdrURL: "WWDR_URL",
    passTypeIdentifier: "pass.**.**.**",
    teamIdentifier: "TEAM_ID",
    password: "PASSWORD",
}

PassKit.initialize(options)
const assets = new PassKit.Assets()
assets.icon = "URL_icon"
assets.icon2x = "URL_icon2x"
assets.logo = "URL_logo"
assets.logo2x = "URL_logo2x"

const pass: PassKit.Pass = {}
pass.primaryFields = [
    {
        "key": "event",
        "label": "hoge",
        "value": "fuga"
    }
]
pass.secondaryFields = [
    {
        "key": "loc",
        "label": "hoge",
        "value": "fuga"
    }
]

const barcode: PassKit.Barcode = {
    altText: "wow",
    format: PassKit.BarcodeFormat.QR,
    message: "http://google.com",
    messageEncoding: "iso-8859-1"
}

const ticket: PassKit.EventTicket = new PassKit.EventTicket(pass, "Organization", "Description", "UUID_string")
ticket.webServiceURL = "https://google.com"
ticket.barcode = barcode
ticket.relevantDate = new Date()
ticket.logoText = "logo_string"
ticket.foregroundColor = new PassKit.RGB(255, 255, 255)
ticket.backgroundColor = new PassKit.RGB(255, 255, 255)
ticket.authenticationToken = "authenticationToken_string"
try {
    const path = await PassKit.generate(ticket, assets)
    console.log(path)
} catch (error) {
    console.log(error)
}

Donation

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文