Skip to content

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

@Latth

Description

@Latth

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions