alexandercerutti / passkit-generator

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

Wallet pass doesn't modify,when uploaded to s3 #199

Closed prashant03Dev closed 4 months ago

prashant03Dev commented 4 months ago

Description

Expected behavior

-As while creating file from buffer part,we are viewing the latest changes made to card,and can be reflected the same to the S3 url that we are generating.

Issue:

As I'cant view the latest changes on wallet pass.

Source Code:

const passCreated: PassKit.PKPass = await this.walletService.createPass(
            'Generic.pass',
            this.user.uuid,
            'membership-card-pass',
        );

        try {
            passCreated.type = this.pass.type;

            passCreated.primaryFields.push({
                key: 'memberName',
                label: 'Member Name',
                value: `${this.user.insuredName}`,
                textAlignment: 'PKTextAlignmentRight',
            });

            passCreated.secondaryFields.push({
                key: 'memberNumber',
                label: 'Member Number',
                value: `${this.user.memberId}`,
                textAlignment: 'PKTextAlignmentRight',
            });

            const buffer = await passCreated.getAsBuffer();

            await fs.writeFile('pass.pkpass', buffer);

            this.logger.debug('======= MEMBERSHIP PASS GENERATED SUCCESSFULLY====');
            const url = await this.s3Service.upload({
                Bucket: '',
                Key: `membership-card/${ulid()}`,
                Body: buffer,
                ContentType: 'application/vnd.apple.pkpass',
            });

@alexandercerutti Can you help me out

alexandercerutti commented 4 months ago

Said that attaching proprietary code like this.walletService.createPass is not very helpful to me to help you, I want to ask you two things:

1) Why are you uploading your pass to S3? 2) Do you already have you pass added to Apple Wallet and you want to download the same pass with updated informations?

prashant03Dev commented 4 months ago

@alexandercerutti

As we are uploading pass to s3,so in future we will update it via sync.

Suggest me if i am wrong,and let me know the ways to sync the pass in mobile device from backend

alexandercerutti commented 4 months ago

@prashant03Dev Update doesn’t work like that.

You need to follow Apple Web Service specifications and integrate the right endpoint and serve the pass as the update pass endpoint is called by Apple Wallet or by sending first a notification via APNS.

Either way, you need to generate a new pass as for each change you need to generate a new manifest and signature.

Therefore, saving a pass on S3 to update it is useless, as you will still need to create it again.

If you are willing to integrate Apple Web Services, I’ve created two packages, one of which is a plugin for Fastify, which will help you to setup only the business logic.

Hope this helps.

prashant03Dev commented 4 months ago

@alexandercerutti can you share the package name,I'm willingly to do that

alexandercerutti commented 4 months ago

https://github.com/alexandercerutti/fastify-passkit-webservice

https://github.com/alexandercerutti/passkit-webservice-toolkit

prashant03Dev commented 4 months ago

@alexandercerutti Just one thing i was thinking about,

After generating a pass from server side,without storing it to s3,Do backend will send the buffer to the app and then they convert it to file and then they show. Is it?

prashant03Dev commented 4 months ago

@alexandercerutti

Q&A

-Do we send the buffer to client side. -If we implement APNS and generate notification from server side,will it be a silent notification or does it notifies to the user on their device.

-Will user tapping on notification redirects to apple wallet app and then he will be shown "do you want to update the pass"?

@alexandercerutti this are my questions in my mind,before implementing the APNS service at backend

alexandercerutti commented 4 months ago

After generating a pass from server side,without storing it to s3,Do backend will send the buffer to the app and then they convert it to file and then they show. Is it?

Yes! That's also why saving to s3 is useless. Passes are just a way to represent data. Data that you already have.

If we implement APNS and generate notification from server side,will it be a silent notification or does it notifies to the user on their device.

I don't have very much experience with APNS and Apple Wallet, so I don't know. I think that's a non-silent notification, as the updated information should have priority in user's mind IMHO.

Imagine a boarding pass that owns boarding gate information. Boarding gate changes but the user didn't check the "time table" yet. Receiving such information could be critical.

Will user tapping on notification redirects to apple wallet app and then he will be shown "do you want to update the pass"?

No. When I received passes updates, I just receive the notification and Apple Wallet opens the pass and highlights what changed. I think the download just happens in background, before sending the notification. I might be wrong tho.

prashant03Dev commented 4 months ago

@alexandercerutti So first time when user clicks on add to wallet,we send the buffer and then they will show it on their wallet.

Then after that if they again hits the add to wallet,we will idenitfy that the user has already passes or not for the specific one,

Is it @alexandercerutti

alexandercerutti commented 4 months ago

So first time when user clicks on add to wallet,we send the buffer and then they will show it on their wallet.

Exactly. You just need to pipe the buffer (or the stream) to the Node HTTP Response.

Then after that if they again hits the add to wallet,we will idenitfy that the user has already passes or not for the specific one,

"Hitting" is ambiguous. User can request a manual update of the pass, but you cannot know when it sees it.

Of couse, when you make the user to download your pass, Apple Wallet should already discard it if the combination of Serial Number, Pass Type Identifier and Team Identifier is the same.

Different is the case in which user requests the update or you send an APNS notification. In that case the serial number is the same and wallet will update it I think.

prashant03Dev commented 4 months ago

@alexandercerutti Got it,Thanks

alexandercerutti commented 4 months ago

Can we close this?

prashant03Dev commented 4 months ago

Yup!