Skip to content

Failed to add pass error #7

Open
@nakajimayoshi

Description

@nakajimayoshi

Upon generating the .pkpass from the file template, the iOS Simulator throws the following error instead of loading the pass:

Failed to add pass: 'file:///Users/dev/Documents/projects/pass/pass.pkpass' Error Domain=PKPassKitErrorDomain Code=1 "No data supplied" UserInfo={NSLocalizedDescription=No data supplied}.

I've used the code from the README to generate the .pkpass:

package main

import (
	"archive/zip"
	"bytes"
	"fmt"
	"io/ioutil"
	"os"

	"github.com/alvinbaena/passkit"
	"github.com/google/uuid"
)

func main() {

	c := passkit.NewGenericPass()

	field := passkit.Field{
		Key:   "key",
		Label: "label",
		Value: "value",
	}

	serial := uuid.NewString()

	fmt.Printf("pass id: %s\n", serial)

	c.AddHeaderField(field)
	c.AddPrimaryFields(field)
	c.AddSecondaryFields(field)
	c.AddAuxiliaryFields(field)
	c.AddBackFields(field)

	pass := passkit.Pass{
		FormatVersion:      1,
		TeamIdentifier:     "==TEAM-ID==",
		PassTypeIdentifier: "==Pass-Identifier==",
		OrganizationName:   "orgName",
		SerialNumber:       serial,
		Description:        "test",
		Generic:            c,
		Barcodes: []passkit.Barcode{
			{
				Format:          passkit.BarcodeFormatQR,
				Message:         "1312312312312312312312312312",
				MessageEncoding: "utf-8",
			},
		},
	}

	template := passkit.NewFolderPassTemplate("passes/mypass.pass")

	signInfo, err := passkit.LoadSigningInformationFromFiles("certs/passmaker.p12", "test", "certs/wwdr.cer")

	signer := passkit.NewMemoryBasedSigner()

	if err != nil {
		panic(err)
	}

	fmt.Print("Pass signed\n")

	z, err := signer.CreateSignedAndZippedPassArchive(&pass, template, signInfo)

	if err != nil {
		fmt.Println("Error creating archive:", err)
		return
	}

	fmt.Print("Archive Created\n")

	err = os.WriteFile("pass.pkpass", z, 0644)

	if err != nil {
		panic(err)
	}

	fmt.Print("Finished creating pass\n")
}

No certificate errors are being thrown, so I think it's safe to say it's not related to certificates/signing.

I'm using the the Generic.pass from Apple as a template, and replaced the values of the JSON with the above fields. I also printed the contents of the pass.json after it was loaded into memory and all the fields were filled out as they were supposed to be, but I still get this error.

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