alexandercerutti / passkit-generator

The easiest way to generate custom Apple Wallet passes in Node.js
MIT License
891 stars 109 forks source link

Card has black text with dark backgroundColor #219

Closed DanielGasparik closed 2 months ago

DanielGasparik commented 2 months ago

Running OS

Cloud Functions

Running Node Version

node v18.0.3

Description

Im basically creating the pass on demand in a cloud function with all the files bundled. The issue is when I set a background color, the text color throughout the whole pass doesn't change at all. This is on iOS 17.6.1. It might not be a bug just me being stuck on Apple's little they have in the docs.

The way of creating the pass

const [signerCert, signerKey, wwdr] = await Promise.all([
      readFile(path.join(certDir, 'signerCert.pem')),
      readFile(path.join(certDir, 'rewardly.key')),
      readFile(path.join(certDir, 'wwdr.pem')),
    ]);

    const backgroundColor = cardTemplate?.template?.colors?.backgroundColor ? hexToRgb(cardTemplate?.template?.colors?.backgroundColor): "rgb(255,255,255)";
    const applePass = await PKPass.from({
      model,
      certificates: {
        signerCert,
        signerKey,
        wwdr,
      },
    }, {
      serialNumber: cardId,
      organizationName: cardTemplate?.template?.organizationName,
      logoText: cardTemplate?.template?.name,
      webServiceURL: "redacted",
      authenticationToken: token,
      backgroundColor: backgroundColor,
    });

Maybe its important to note, I m also setting a stripImage.png with .addBuffer since the image is stord in cloud storage.

Expected behavior

White text on black background

Steps to reproduce

Were you able to verify it by using (and changing) the examples?

If yes, which changes did you apply?

Other details

alexandercerutti commented 2 months ago

Hi @DanielGasparik, thanks for using passkit-generator!

The text color doesn't change automatically with the backgroundColor. There are two different property for that: foregroundColor and labelColor. I don't know what is the one you are referring to, but might be both.

Let me know if setting these two, solves your problem.

DanielGasparik commented 2 months ago

Added labelColor rgba to both and it works :) Thank you so much! Love the library.

alexandercerutti commented 2 months ago

Thank you for you donation ❤️