justdmitry/PassKitHelper

The pass “pass_name.pkpass” could not be opened.

aravindhjahan25 opened this issue · 11 comments

Generated Pass - 'The pass “Sample.pkpass” could not be opened.' show like this and
I shared this pass via email but it does not take into iPhone/iPad Wallet App.

I am also facing the same issue.

  public static async Task Main()
        {
            var options = new PassKitOptions()
            {
                // See `how_to_create_pfx.md` to create your onw pfx file  
                PassCertificate = new X509Certificate2(File.ReadAllBytes("C:\\Users\\krishnakumar.k\\Downloads\\PassKitHelper-master\\PassKitHelper-master\\PassKitHelper.Demo\\images\\pass.pfx"),"password"),
                
                AppleCertificate = new X509Certificate2(File.ReadAllBytes("C:\\Users\\krishnakumar.k\\Downloads\\PassKitHelper-master\\PassKitHelper-master\\PassKitHelper.Demo\\images\\AppleWWDRCAG3.cer")),
                ConfigureNewPass =
                    p =>
                        p.Standard
                            .PassTypeIdentifier("pass.com.apple.devpubs.example")
                            .SerialNumber("PassKitHelper")
                            .TeamIdentifier("A93A5CM278")
                            .OrganizationName("PassKit")
                        .VisualAppearance
                            .LogoText("COVID-19 Vaccination Record Card")
                        .Generic
                            .AuxiliaryFields
                                .Add("github")
                                    .Label("GitHub link")
                                    .Value("https://github.com/justdmitry/PassKitHelper"),
            };

           // var passKitHelper = new PassKitHelper(options);
            IPassKitHelper passKitHelper = new PassKitHelper(options);
            await GenerateSamplePass(passKitHelper);

            //// uncomment to send push notification
            //// attention! your pass (you push update for) must already include WebService fields (auth.token and endpoint), and your web service/app must be up and running
            //// var registrationPushToken = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
            //// var ok = await passKitHelper.SendPushNotificationAsync(registrationPushToken);
        }

        public static async Task GenerateSamplePass(IPassKitHelper passKitHelper)
        {
            var pass = passKitHelper.CreateNewPass()
                .Standard
                    .Description("PassKitHelper demo pass")
                ////.WebService
                ////    .AuthenticationToken("some-nonce")
                ////    .WebServiceURL("https://www.example.com/")
                .VisualAppearance
                    .Barcodes("1234567890128", BarcodeFormat.QR)
                    .ForegroundColor("rgb(44, 62, 80)")
                    .BackgroundColor("rgb(149, 165, 166)")
                    .LabelColor("rgb(236, 240, 241)")
                .Generic
                    .PrimaryFields
                        .Add("version")
                            .Label("Library version")
                            .Value(typeof(IPassKitHelper).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion)
                ;

            var package = await passKitHelper.CreateNewPassPackage(pass)
                .Icon(await File.ReadAllBytesAsync("C:\\Users\\krishnakumar.k\\Downloads\\PassKitHelper-master\\PassKitHelper-master\\PassKitHelper.Demo\\images\\icon.png"))
                .Icon2X(await File.ReadAllBytesAsync("C:\\Users\\krishnakumar.k\\Downloads\\PassKitHelper-master\\PassKitHelper-master\\PassKitHelper.Demo\\images\\icon@2x.png"))
                .Logo(await File.ReadAllBytesAsync("C:\\Users\\krishnakumar.k\\Downloads\\PassKitHelper-master\\PassKitHelper-master\\PassKitHelper.Demo\\images\\logo.jpg"))
                //.Strip(await File.ReadAllBytesAsync("C:\\Users\\krishnakumar.k\\Downloads\\PassKitHelper-master\\PassKitHelper-master\\PassKitHelper.Demo\\images\\strip.jpg"))
                //.Strip2X(await File.ReadAllBytesAsync("C:\\Users\\krishnakumar.k\\Downloads\\PassKitHelper-master\\PassKitHelper-master\\PassKitHelper.Demo\\images\\strip@2x.jpg"))
                .SignAndBuildAsync();

            await File.WriteAllBytesAsync("Sample.pkpass", package.ToArray());
        }

Some images are required. Try uncomment (return) Strip2x image back.

Now the file generated in windows. Can I share the file through the mail and verify it in IOS?

Double-check that you put correct PassTypeIdentifier and TeamIdentifier and they matches your certificate. My demo works correct only after replacing this values to your own (it generates passes anyway, but pass opens on my iPhone only when correct values are provided).

Hi Dmitry ,

After generating a new pfx file, We can able to generate and preview the file in MAC, But I downloaded the same file in mobile and try to open it, I couldn't Add it.
Screenshot 2021-01-13 at 5 31 13 PM (1)

Thanks

am also facing the same issue. I successfully generated the .pkpass file and able to see the preview in mac laptop. I shared it via email to my iPhone the pkpass file not added to my apple wallet.

When I make invalid passes - iPhone does not display them at all. So, if you can view pass on iPhone but can't add it to Wallet - it's something other, not file. Can you share generated file somehow?

I have attached the sample file here in zip format. Because .pkpass format not supported to attach. Please change the file format and verify.

Sample.zip

Thanks

It's not opening on my phone. Double-check that you used correct PassTypeIdentifier and TeamIdentifier, and correct PFX, and so on. I never tried to build passes on Mac, so if you have some kind of VM with Windows - try build inside it.

Hi,

Now it's working after used the new AppleWWDRCA.cer file "2023". But the bar code does not generate like yours, Instead of added multiple lines. We are using "BarcodeFormat.Code128" format only.
image

How to change the font size. Because Secondary and Auxiliary fields are showing different sizes and styles.

Thanks

Oh, old/expired certificate can cause issues with signing and validating, good point.

Barcode - unzip pass and check pass.json - may be you put some "strange" (non-latin) characters into "message" ?

Font size - you can't change it. Apple asks only color, but layout management is done by your phone itself. Change texts (length) until you satisfied how it rendered.