Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create correct NFC enabled pkpass or can't pass it to the wallet. #108

Open
Latth opened this issue Jan 23, 2025 · 9 comments
Open

Comments

@Latth
Copy link

Latth commented Jan 23, 2025

Package

apple_passkit

Problem Statement

Hello, I have an issue when im making an Apple Wallet app.

I've created the pkpass file succesfully but when i try to add it to Wallet i have an error.

Error;
flutter: Error: PlatformException(invalid, Received data is not a valid PKPass, The pass cannot be read because it isn’t valid., null) 

How I create the pkpass file; Stars added for privacy by me on app there are no stars.

 // Generate PkPass file
      final pass = PkPass(
        pass: PassData(
          formatVersion: 1, // Certificate
          passTypeIdentifier: 'pass.nl.twogomobile.flutterwalletapp',
          serialNumber: 'XI****-PASS-2255', // Certificate
          description: 'Test',
          organizationName: 'Test App',
          teamIdentifier: 'PT6K******',
          barcode: Barcode(
            message: '123456789',
            format: PkPassBarcodeType.qr,
            messageEncoding: 'iso-8859-1',
          ),
        ),

        icon: PkImage(image1: iconBytes, image2: icon2XBytes),
        logo: PkImage(image1: logoBytes),
      );

      // .pkpass generate
      Uint8List? binaryData = pass.write(
        certificatePem: certificatePem,
        privateKeyPem: privateKeyPem,
      );

      // .pkpass write the file.
      final pkPassPath = '${directory.path}/pass.pkpass';
      File(pkPassPath).writeAsBytesSync(binaryData!);

How i read and try to add on Wallet;

      // .pkPass dosyasını oku
      Uint8List pkPassUint8 = File(pkPassPath).readAsBytesSync();



      // first check whether PassKit is available
      bool isAvailable = await passKit.isPassLibraryAvailable();
      // then check whether you can actually add passes
      bool canAddPasses = await passKit.canAddPasses();

      // when both of them are true, you can add a pass.
      if(isAvailable && canAddPasses) {
        await passKit.addPass(pkPassUint8);
      }

Solution Brainstorm

No response

Are you willing to submit a PR?

None

@Latth Latth changed the title Can't create correct pkpass. Can't create correct pkpass or can't pass it to the wallet. Jan 23, 2025
@ueman
Copy link
Owner

ueman commented Jan 23, 2025

final pass = PkPass(
  pass: PassData(
    formatVersion: 1, // Certificate
    passTypeIdentifier: 'pass.nl.twogomobile.flutterwalletapp',
    serialNumber: 'XI****-PASS-2255', // Certificate
    description: 'Test',
    organizationName: 'Test App',
    teamIdentifier: 'PT6K******',
    barcode: Barcode(
      message: '123456789',
      format: PkPassBarcodeType.qr,
      messageEncoding: 'iso-8859-1',
    ),
  ),

  icon: PkImage(image1: iconBytes, image2: icon2XBytes),
  logo: PkImage(image1: logoBytes),
);

Is that the whole data you add to the pass? If so, that's most likely the reason, since that can't result in a valid pass.

@Latth
Copy link
Author

Latth commented Jan 23, 2025

final pass = PkPass(
pass: PassData(
formatVersion: 1, // Certificate
passTypeIdentifier: 'pass.nl.twogomobile.flutterwalletapp',
serialNumber: 'XI****-PASS-2255', // Certificate
description: 'Test',
organizationName: 'Test App',
teamIdentifier: 'PT6K******',
barcode: Barcode(
message: '123456789',
format: PkPassBarcodeType.qr,
messageEncoding: 'iso-8859-1',
),
),

icon: PkImage(image1: iconBytes, image2: icon2XBytes),
logo: PkImage(image1: logoBytes),
);
Is that the whole data you add to the pass? If so, that's most likely the reason, since that can't result in a valid pass.

Hey again! Thank for your quick answer! yeah we created it for test app before intergrate to the main app. Could you please provide me a correct passData? I would be really happy about it.

@ueman
Copy link
Owner

ueman commented Jan 23, 2025

Apple has a couple examples here.

Alternatively, take a look at the links here: #23

@Latth
Copy link
Author

Latth commented Jan 23, 2025

Hey! thanks for your all informations. We successfully got the view for the Wallet Add. But when we add nfc(we need to use it) I still get same error. Do i have to pass a "encryptionPublicKey"? is it neccessary?

        nfc: Nfc(
          message: 'Test Value',
          requiresAuthentication: false,
        ),

@ueman
Copy link
Owner

ueman commented Jan 23, 2025

Unfortunately, I can't help you with that. I don't have any access to things needed to create or test NFC passes. If you figure it out, please let me know

@ueman
Copy link
Owner

ueman commented Jan 23, 2025

@Latth Do you use a NFC Pass Type Identifier Certificate and a NFC pass type identifier? Your company probably needs to get some special permit from Apple for it

@ueman
Copy link
Owner

ueman commented Jan 25, 2025

Note to self: Write a disclaimer for NFC passes in the readme

@Latth
Copy link
Author

Latth commented Feb 25, 2025

@Latth Do you use a NFC Pass Type Identifier Certificate and a NFC pass type identifier? Your company probably needs to get some special permit from Apple for it

Hello! i am just testing on myself rigjt now. on emulator, still doesnt work for me. Did you find something more about it?

@ueman
Copy link
Owner

ueman commented Feb 25, 2025

No, if you or anyone else can provide me with a valid NFC certificate and so on, I can try looking into it. Without those things there's nothing I can do.

You can try generating NFC enabled passes with some other software that's out there (there's a good JS based software out there) and compare it to what this package does. Maybe that gives you some pointers to try to fix things.

@ueman ueman changed the title Can't create correct pkpass or can't pass it to the wallet. Can't create correct NFC enabled pkpass or can't pass it to the wallet. Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants