Added support for personalization / Rewards Enrollment passes

This commit is contained in:
Alexander Cerutti
2019-07-27 00:41:48 +02:00
parent 2444d52cb2
commit eecfdb048f
2 changed files with 59 additions and 6 deletions

View File

@@ -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;
/**