Coder Social home page Coder Social logo

passsharp's Introduction

PassSharp

Travis CIBuild Status AppVeyor Build Status NuGet

An Apple Wallet Passbook Library in C#/.NET supporting iOS 6+

Install PassSharp

PM> Install-Package PassSharp

or

$ nuget install PassSharp

Creating Passes

You will need to use the Pass class to set the necessary fields for the type of pass you want to create. (See Apple's Pass Design and Creation documentation)

var pass = new Pass {
  type = PassType.generic,
  passTypeIdentifier = "pass.com.my.pass",
  description = "example pass",
  organizationName = "acme corp",
  "serialNumber" = "abc123456",
  teamIdentifier = "U1234567",
  icon = new Asset("path/to/icon"),
  icon2x = new Asset("path/to/icon2x"),
  icon3x = new Asset("path/to/icon3x"),
  logo = new Asset("path/to/logo"),
  logo2x = new Asset("path/to/logo2x"),
  logo3x = new Asset("path/to/logo3x")
};

You can now set more general fields (such as location, barcode, etc.).

pass.addLocation({ longitude: 10.0000, latitude: -10.0000 });
pass.addBarcode(new Barcode {
  message = "1234",
  format = BarcodeFormat.PKBarcodeFormatPDF417
});
pass.addField(FieldType.Header,
  new Field {
    key = "pass-field",
    label = "pass-field-label",
    value = "pass-field-value"
  }
);
pass.addField(FieldType.Primary,
  new Field {
    key = "pass-field2",
    label = "pass-field-label2",
    value = "pass-field-value2"
  }
);

Writing Passes & Certificates

In order to create passes you will need to download the Apple WWDR intermediate certificate, and to generate your own pass id certificate from the Apple developers portal.

You can then write passes by including the Apple WWDR certificate, and the pass id certificate that you previously generated.

var myPass = new Pass { ... };
using(var myStream = new MemoryStream()) {
  PassWriter.Write(myPass, myStream,
    new X509Certificate2("../path/to/appleWWDRCertificate"),
    new X509Certificate2("../path/to/passCertificate"));
}

passsharp's People

Contributors

nmonasterio avatar scurker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

passsharp's Issues

That last step...

I have that last step as being this :
using (var myStream = new MemoryStream())
{
PassWriter.WriteToStream(myPass, myStream,
new X509Certificate2("MyFiles/AppleWWDRCA.cer"),
new X509Certificate2("MyFiles/Certificates.p12", "mypassword"));

        }

But I am getting two exceptions :

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'ServiceStack.Text.JsConfig' threw an exception.
Source=ServiceStack.Text
StackTrace:
at ServiceStack.Text.JsConfig.CreateScope(String config, JsConfigScope scope)
at PassSharp.PassWriter.ToJson(Pass pass)
at PassSharp.PassWriter.WriteToStream(Pass pass, Stream stream, X509Certificate2 appleCert, X509Certificate2 passCert)
at PasskitServer.Controllers.PassesController.Get(String PassTypeId, String LoyGUID) in C:\Users\punky\Documents\Visual Studio 2017\Projects\PasskitServer\PasskitServer\Controllers\PassesController1.cs:line 74
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()

Inner Exception 1:
TypeInitializationException: The type initializer for 'ServiceStack.LicenseUtils' threw an exception.

Inner Exception 2:
FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

Can someone point out what I am doing wrong?

Invalid provider type specified.

Hi, In the code
PassWriter.WriteToStream(pass, ms,
new X509Certificate2(certWDRData),
new X509Certificate2(certPassData, Password));

I'm getting an error saying Invalid provider type specified.
So, what am I doing wrong...

to json exption

when i try to run the demo i got the following error in .tojson function
The type initializer for 'ServiceStack.Text.JsConfig' threw an exception. that he can not find the pass.json
isnt it suppose to be created?

Expiration Date exception when trying to load pass on device or simulator

Unable to parse expirationDate /Date(1487415600000-0000)/ as a date. We expect dates in "W3C date time stamp format", either "Complete date plus hours and minutes" or "Complete date plus hours, minutes and seconds". For example, 1980-05-07T10:30-05:00.

using C# DateTime on the Pass.expirationDate field, if I leave this field out (which I really can't) the pass works fine
Help :) ?!

issue in PassWriter.WriteToFile()

While i was creating a .pkpass file with writetofile() function then there is an exception like System.Security.Cryptography.CryptographicException: 'Keyset does not exist. Can you please help me out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.