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

PKPass instantiation #2

Open
jgbrittos opened this issue Jul 7, 2017 · 0 comments
Open

PKPass instantiation #2

jgbrittos opened this issue Jul 7, 2017 · 0 comments

Comments

@jgbrittos
Copy link

jgbrittos commented Jul 7, 2017

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;
        }
    }
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

1 participant