Example #1
0
        public static async Task Main()
        {
            var options = new PassKitOptions()
            {
                // See `how_to_create_pfx.md` to create your onw pfx file
                PassCertificate  = new X509Certificate2(File.ReadAllBytes("pass.pfx")),
                AppleCertificate = new X509Certificate2(File.ReadAllBytes("AppleWWDRCA.cer")),
                ConfigureNewPass =
                    p =>
                    p.Standard
                    .PassTypeIdentifier("pass.com.apple.devpubs.example")
                    .TeamIdentifier("A93A5CM278")
                    .OrganizationName("PassKit")
                    .VisualAppearance
                    .LogoText("PassKit Helper demo")
                    .StoreCard
                    .AuxiliaryFields
                    .Add("github")
                    .Label("GitHub link")
                    .Value("https://github.com/justdmitry/PassKitHelper"),
            };

            var passKitHelper = new PassKitHelper(options);

            await GenerateSamplePass(passKitHelper);

            //// uncomment to send push notification
            //// attention! your pass (you push update for) must already include WebService fields (auth.token and endpoint), and your web service/app must be up and running
            //// var registrationPushToken = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
            //// var ok = await passKitHelper.SendPushNotificationAsync(registrationPushToken);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PassKitHelper"/> class.
 /// </summary>
 /// <param name="options">Configured options.</param>
 /// <param name="httpClientAccessor">HttpClient accessor/factory.</param>
 /// <remarks>
 /// Constructor for use in webapp (used when <see cref="Microsoft.Extensions.DependencyInjection.PassKitHelperServiceCollectionExtensions.AddPassKitHelper(Microsoft.Extensions.DependencyInjection.IServiceCollection, Action{PassKitOptions})"/> called from your Startup.cs file).
 /// </remarks>
 public PassKitHelper(PassKitOptions options, Func <HttpClient> httpClientAccessor)
 {
     this.options            = options ?? throw new ArgumentNullException(nameof(options));
     this.httpClientAccessor = httpClientAccessor;
 }