google-wallet / pass-converter

Tool to convert passes for different wallet apps from one format to another
Apache License 2.0
209 stars 29 forks source link

getting safari cannot download this file (applepass-95370f2a-cd77-4bcc-b52b-be22dff45415.pkpass) #24

Closed fahisayub closed 1 year ago

fahisayub commented 1 year ago

I am using Pass converter to convert Google Pass to Apple Pass, the output is stored in the AWS S3. when a user visit the link it will download the .pkpass (naming is like this: applepass-95370f2a-cd77-4bcc-b52b-be22dff45415.pkpass). but I am getting "Safari cannot download this file" when I am using iPhone 14.

in windows by changing the user agent, it is getting downloaded

any idea how to fix this, screenshot attached below this is the code that sent pkpass to s3 and get back the link

`if (req.passText.charAt(0) === '{') {

        try {
            const pkPassBuffer = await googleToPkPass(JSON.parse(req.passText), req.fullUrl);
            // Respond with the PKPass file
            const params = { content: pkPassBuffer, contentType: 'application/vnd.apple.pkpass', }
            const applePassUrl = await uploadToS3(params);
            res.send({ msg: 'success', url: applePassUrl })
        } catch (e) {
            console.log(e);
        }

    }`

upload to S3 :
` // function that upload pkpass to s3

 const uploadToS3 = async ({ content, contentType }) => {
 let random = seedrandom(`${new Date().getTime()}`)();
 const keyId = uuidv4(`link/${random}`, uuidv4.URL);
 const params = {
  Bucket: bucket,
   Key: `applepass-${keyId}.pkpass`,
   Body: content,
  ContentEncoding: "base64",
   ContentType: contentType,
   };

  const uploadedfile = await s3.upload(params).promise();
   return uploadedfile.Location.replace("s3.amazonaws.com/", "");
  }; `

Screenshot (1169)

I used pass validator to validate the pass, it says : image

stephenmcd commented 1 year ago

Sounds like an issue between S3 and your device.

You could potentially verify this by downloading the pass file and opening it on a Mac or emailing it to your iPhone.

fahisayub commented 1 year ago

I tried emailing after fixing the issue with webserviceURL and icons, but still, i get the same error that Safari cannot download this file.

stephenmcd commented 1 year ago

Try the troubleshooting steps here: https://github.com/google-wallet/pass-converter#apple-pkpass-2

fahisayub commented 1 year ago

I am using a Windows device, and when I switch user-agent it downloads the pkpass file but, when I use an ios simulator it says the same "Safari cannot download this file" I checked with a real ios device and the result is the same.

but, when I tried opening the pass through the mail app it's working, and the pass is displaying. Previously opened the mail through the browser itself, is it the issue with the browser

stephenmcd commented 1 year ago

If you're unable to follow the debugging steps there's not much else I can suggest, please post back here if you find the solution.

fahisayub commented 1 year ago

yes, I got the issue it was because of the headers since I am using aws for storing the pkpass file when I return it for download I am sending it as json content type instead of contentType: 'application/vnd.apple.pkpass',

The reason for showing error "Safari cannot download this file is mainly due to :

Thank you for guiding me

stephenmcd commented 1 year ago

Thanks so much for posting the solution, it will definitely help others who face it.