mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-16 00:25:30 +00:00
Added support for personalization / Rewards Enrollment passes
This commit is contained in:
17
src/pass.ts
17
src/pass.ts
@@ -7,7 +7,7 @@ import { ZipFile } from "yazl";
|
||||
import * as schema from "./schema";
|
||||
import formatMessage from "./messages";
|
||||
import FieldsArray from "./fieldsArray";
|
||||
import { generateStringFile, dateToW3CString, isValidRGB } from "./utils";
|
||||
import { generateStringFile, dateToW3CString, isValidRGB, deletePersonalization, getAllFilesWithName } from "./utils";
|
||||
|
||||
const barcodeDebug = debug("passkit:barcode");
|
||||
const genericDebug = debug("passkit:generic");
|
||||
@@ -134,6 +134,21 @@ export class Pass {
|
||||
// Editing Pass.json
|
||||
this.bundle["pass.json"] = this._patch(this.bundle["pass.json"]);
|
||||
|
||||
/**
|
||||
* Checking Personalization, as this is available only with NFC
|
||||
* @see https://apple.co/2SHfb22
|
||||
*/
|
||||
const currentBundleFiles = Object.keys(this.bundle);
|
||||
|
||||
if (!this[passProps].nfc && currentBundleFiles.includes("personalization.json")) {
|
||||
genericDebug(formatMessage("PRS_REMOVED"));
|
||||
deletePersonalization(this.bundle, getAllFilesWithName(
|
||||
"personalizationLogo@",
|
||||
currentBundleFiles,
|
||||
"startsWith"
|
||||
));
|
||||
}
|
||||
|
||||
const finalBundle = { ...this.bundle } as schema.BundleUnit;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user