0

i am implementing a ios app with Passbook. so i have implemented ASP.net server to generate a pass. the pass was generated successfully from server side. and also when i double click on the pass.pkpass file from my mac, pass viewer is showing my pass which i created from the server. but when im trying to drag it to IOS simulator it is said that "safari can not download this file". i have tried by regenerating certificates. but nothing worked.

here is my pass.json file

  {
  "passTypeIdentifier": "<mypassIdenttity>",
  "formatVersion": 3,
  "organizationName": "<my organization name>",
  "serialNumber": "<my serial number>",
  "teamIdentifier": "<my team identifier>",
  "description": "123",
  "foregroundColor": "rgb(255,255,255)",
  "backgroundColor": "rgb(55,117,50)",
  "logoText": "Zekes",
  "barcode": {
  "message": "123456789",
  "format": "PKBarcodeFormatPDF417",
  "messageEncoding": "iso-8859-1"
  },
  "storeCard": {
  "primaryFields": [
  {
    "key": "balance",
    "label": "remaining balance",
    "value": 21.75
  }
 ],
 "auxiliaryFields": [
  {
    "key": "deal",
    "label": "Deal of the Day",
    "value": "Lemons"
  }
]
 }
}

here is my manifest.json

 {
  "pass.json": "285c63c6580d946eb360e0c6e68d1fa072ea20e9",
  "logo.png": "25de09e2d3b01ce1fe00c2ca9a90a2be1aaa05cf",
  "icon.png": "0296b01347b3173e98438a003b0e88986340b2d8",
  "icon@2x.png": "5afd9585b08c65fdf105a90c8bd643407cba2787",
  "strip.png": "736d01f84cb73d06e8a9932e43076d68f19461ff",
  "strip@2x.png": "468fa7bc93e6b55342b56fda09bdce7c829d7d46"
 }

i have exported my pass certificate as P12 file and the privateKey as P12 file. and copied them into my project path[in the server implementation]

here is how i generating my signature file using manifest and the certificate file.

static void SignManifest(ZipFile zipFile, byte[] manifestFileData, X509Certificate2 certificate)
    {
        var cert = DotNetUtilities.FromX509Certificate(certificate);

        var privateKey = DotNetUtilities.GetKeyPair(certificate.PrivateKey).Private;
        var generator = new CmsSignedDataGenerator();

        generator.AddSigner(privateKey, cert, CmsSignedDataGenerator.DigestSha1);

        var certList = new System.Collections.ArrayList();
        ////////////////////////////////////////////////////////
       var a1Cert = new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwrd.cer"));
      // var a2Cert = new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AppleIncRootCertificate.cer"));
        ///////////////////////////////////////////////////////////
        certList.Add(cert);
      certList.Add(DotNetUtilities.FromX509Certificate(a1Cert));
        //certList.Add(DotNetUtilities.FromX509Certificate(a2Cert));

        Org.BouncyCastle.X509.Store.X509CollectionStoreParameters PP = new Org.BouncyCastle.X509.Store.X509CollectionStoreParameters(certList);
        Org.BouncyCastle.X509.Store.IX509Store st1 = Org.BouncyCastle.X509.Store.X509StoreFactory.Create("CERTIFICATE/COLLECTION", PP);

        generator.AddCertificates(st1);

        var content = new CmsProcessableByteArray(manifestFileData);
        var signedData = generator.Generate(content, false);

        var data = signedData.GetEncoded();

        zipFile.AddEntry("signature", data);   
    }

i can successfully generate the pass.pkpass but why it is not runing in the simulator?.. can someone tell me the reason ? im really stuck in here for two days now.. please help me.

Darshana
  • 314
  • 2
  • 4
  • 22
  • What do the console logs tell you? – PassKit Nov 21 '14 at 09:47
  • @PassKit i havent tried to load it from an ios app yet.. but i know that passes can load by drag and drop to the simulator. so i dont have console log output for now.. – Darshana Nov 21 '14 at 10:06
  • You can still open up console as you drag in the .pkpass bundle. It should give you some insight into what is happening. – PassKit Nov 21 '14 at 10:35
  • no i cant see any thing in log – Darshana Nov 21 '14 at 10:56
  • Perhaps consider installing the bundle on a web server and then navigating to the url to install the pass. Don't forget to set the MIME type. – PassKit Nov 22 '14 at 01:41
  • but it should be work by drag and drop to the simulator. i have tried a pre-configured pkpass file. that works fine. i have followed the same json file.only the information changed there in my pkpass. i cant solve this :( – Darshana Nov 24 '14 at 05:09
  • Can you put your .pkpass bundle online somewhere and post a link so I can take a look at it? – PassKit Nov 24 '14 at 07:43

1 Answers1

0

According to the Passbook documentation, the formatVersion should always be 1.

https://developer.apple.com/library/ios/documentation/UserExperience/Reference/PassKit_Bundle/Chapters/TopLevel.html

wspruijt
  • 1,037
  • 11
  • 15