Skip to content

PKPass instantiation #2

@jgbrittos

Description

@jgbrittos

Hi,

Thanks in advance for this library!

I'm trying to create a Wallet pass and it is not working.

I already have a certificate.p12 and when a run the sample code it generates a pass.pkpass, but pass not open.

Any clue?

My code:

static PassKit CreatePass() {

            var pk = new PassKit();
            pk.PassType = PKPassType.EventTicket;
            pk.FormatVersion = 1;
            pk.PassTypeIdentifier = "pass.br.com.wizsolucoes.seguros";
            pk.SerialNumber = "0988890";
            pk.TeamIdentifier = "LUT4N73CY2";
            pk.WebServiceURL = "https://pacific-plateau-64319.herokuapp.com";
            pk.AuthenticationToken = "42977B70AE924C6EA7479CFAF3F4FCC1";
            pk.OrganizationName = "Wiz";
            pk.Description = "MOBILIZE";
            pk.LogoText = "SOME TEXT";
            pk.BackgroundColor = PKColor.Parse("rgb(61, 104, 165)");
            pk.ForegroundColor = PKColor.Parse("rgb(255, 255, 255)");
            pk.LabelColor = PKColor.Parse("rgb(255, 255, 255)");
            pk.Barcode = new PKBarcode(PKBarcodeFormat.PKBarcodeFormatQR, "Oi", "Oi de novo", "Oi mais uma vez");

            var stripImage = new PKImage();
            stripImage.Filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "img/strip.png");
            stripImage.HighResFilename = stripImage.Filename;
            stripImage.Data = File.ReadAllBytes(stripImage.Filename);
            stripImage.HighResData = stripImage.Data;
            pk.Strip = stripImage;

	    var thumbnailImage = new PKImage();
	    thumbnailImage.Filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "img/thumbnail.png");
            thumbnailImage.HighResFilename = thumbnailImage.Filename;
            thumbnailImage.Data = File.ReadAllBytes(stripImage.Filename);
            thumbnailImage.HighResData = thumbnailImage.Data;
            pk.Thumbnail = thumbnailImage;

            var iconImage = new PKImage();
            iconImage.Filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "img/icon.png");
            iconImage.HighResFilename = iconImage.Filename;
            iconImage.Data = File.ReadAllBytes(stripImage.Filename);
            iconImage.HighResData = iconImage.Data;
            pk.Icon = iconImage;

            var logoImage = new PKImage();
            logoImage.Filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "img/logo.png");
            logoImage.HighResFilename = logoImage.Filename;
            logoImage.Data = File.ReadAllBytes(stripImage.Filename);
            logoImage.HighResData = logoImage.Data;
            pk.Logo = logoImage;

            var sf = new PKPassFieldSet();
            sf.Add(new PKPassStringField() { Key = "test", Label = "My Test", Value = "This is my test!" });
            sf.Add(new PKPassStringField() { Key = "test1", Label = "My Test1", Value = "This is my other test!" });
            pk.SecondaryFields = sf;

            var af = new PKPassFieldSet();
            af.Add(new PKPassStringField() { Key = "test2", Label = "My Test2", Value = "This is my test!2" });
            af.Add(new PKPassStringField() { Key = "test3", Label = "My Test3", Value = "This is my other test!3" });
            pk.AuxiliaryFields = af;

            var bf = new PKPassFieldSet();
            bf.Add(new PKPassStringField() { Key = "test4", Label = "My Test4", Value = "This is my test!4" });
            bf.Add(new PKPassStringField() { Key = "test5", Label = "My Test5", Value = "This is my other test!5" });
            pk.BackFields = bf;

            return pk;
        }
    }

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