WebEferen / flutter_wallet_card

Flutter Wallet Card plugin (iOS & Android)
MIT License
11 stars 21 forks source link

Nfc pass #10

Closed sachin-ngendev closed 10 months ago

sachin-ngendev commented 10 months ago

can you provide more info about how to add a nfc card to pass that have specific data to open doors that works on rfid

WebEferen commented 10 months ago

Hello, @sachin-ngendev

Give me the example data you want to store inside NFC Pass and I will try to make an example out of it to showcase the option.

WebEferen commented 10 months ago

Firstly you need to create passkit object with Apple issued public key (base64 format) and payload message.

final nfcPasskit = PasskitNfc(encryptionPublicKey: '', message: 'Some_NFC_MESSAGE');

Secondly, you will need to create passkit for the particular pass:

final passkit = PasskitPass(
  formatVersion: 1,
   passTypeIdentifier: '',  // fill required fields
   description: '',  // fill required fields
   teamIdentifier: '',  // fill required fields
   organizationName: '',  // fill required fields
   serialNumber: '', // fill required fields
   nfc: nfcPasskit, // provide the nfc class created earlier
);

Then you should be able either to use your own signature keys or generate new ones (in this example I'm using stub generation of the empty signature -> this will not work if you'd like to import generated passkit.

To make it work, take a look on the Signer class (and how to generate signature certificate). Stubs I'm making will look like this:

final directory = Directory('.input'); // directory for temporary files (such as signature/pass.json/manifest.json)
final creators = Creators(directory: directory); // creators helper
final signature = await creators.createEmptySignature(); // create empty stub signature (you should be using class Signer() instead).

With the generated signature, you should be able to create passkit file and manifest with it's checksum using creator utility:

final pkpass = await creators.createPass(passkit);
final manifest = await creators.createManifest({'pass.json': pkpass.readAsBytesSync()});

Finally, passkit can be generated:

final result = await Passkit(directoryName: '_test_').generate(
  id: 'some-id',
  directory: directory,
  passkitPass: passkit,
  pkpass: pkpass,
  signature: signature,
   manifest: manifest,
);

Let me know if that helped you. For the Signer class how-to - take a look on the Signer tests.