PassKit on iOS 6

32,416 views

Published on

Craig Dunn walks us through an introduction of PassKit and how you can take advantage of using this functionality from your MonoTouch applications.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
32,416
On SlideShare
0
From Embeds
0
Number of Embeds
26,865
Actions
Shares
0
Downloads
27
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

PassKit on iOS 6

  1. 1. PassKit on iOS 6 Craig Dunn
  2. 2. What is a Pass?
  3. 3. What is a Pass? “ unique n umber”Simple: a Barcode Delivery System
  4. 4. What is a Pass? ii• 5 Types : Coupon, Generic, StoreCard, BoardingPass, EventTicket• Barcode (2D formats)• What’s behind the scenes? • Barcode • (hidden) SerialNumber is the unique Id you can use this to stop duplicates * not same as the barcode data, so you can show the same barcode to many users
  5. 5. What is a Pass? iii {• ZIP file "passTypeIdentifier":"com.xamarin.passkitdoc.banana", "formatVersion":1, "organizationName":"Xamarin", "serialNumber":"12345436XYZ", • Pass.json "teamIdentifier":"XXXAAA1234", "description":"Xamarin Demo", "foregroundColor":"rgb(54,80,255)", "backgroundColor":"rgb(209,255,247)", • Images "labelColor":"rgb(255,15,15)", "logoText":"Banana ", "barcode":{ "altText":"FREE-BANANA", "format":"PKBarcodeFormatQR", "message":"123456", "messageEncoding":"iso-8859-1" }, /* The following fields are specific to which type of pass. The name of this object specifie boardingPass below implies this is a boarding pass. Other options include storeCard, generic, eventTicket */ "boardingPass":{ /*headerFields, primaryFields, secondaryFields, and auxiliaryFields are arrays of field object key, label, and value*/ "headerFields":[ //Header fields appear next to logoText { "key":"h1-label", //Must be unique. Used by iOS apps to get the data. "label":"H1-label", //Label of the field "value":"H1" //The actual data in the field },
  6. 6. (extra bits) What is a Pass? iv• Relevance : locations (<10) & datetime (1 only) "relevantDate" : "2012-10-17T09:00-05:00", "locations" : [ { "longitude" : -122.3748889, "latitude" : 37.6189722 },{ "longitude" : -122.03118, "latitude" : 37.33182• }], Related App Store apps "associatedStoreIdentifiers" : [562123362],• Custom text "backFields" : [ { "key" : "terms", "label" : "TERMS AND CONDITIONS", "value" : "Generico offers this pass......"• Web Service URL : register/delete/APNS pull updates "webServiceURL" : "https://example.com/passes/", "authenticationToken" : "qwerty123567890asdfpoiuyt",
  7. 7. (manifest & sign) Make a Pass• Must be an “Apple Developer”• Provisioning Portal : Pass Type ID • identifier starts with “pass.”• Requires various root certificates• signpass app provided by Apple
  8. 8. Make a Pass ii• Edit JSON• Edit images• (manifest & sign) DEMO(?)• ZIPApple’s sample (you have to build yourself)https://developer.apple.com/downloads/index.action?name=Passbook
  9. 9. (testing) Make a Pass iii• Watch Console (Xcode) • Log should tell you what went wrong• HTTP (non-secure) can be used only while testing APNS+updates
  10. 10. Scan Pass push update notification Add Pass Apple APNS servers Passbook Update database Scanner register request notification pass changed of change data P.O.S. generate & sign pass web Your make changes to pass service Add Pass certificate for signing passes server sign-pass images and JSON resources used to generate passesCompanion Apps pass & device Your app database email attachments web links Conduit Mail Safari Apps (others)
  11. 11. Passbook• Stores & manages Passes• Renders barcode for scanning (Apple: your app should not perform this function)• Receives notifications and makes web-service calls
  12. 12. (Pass pass-thru) Conduit Apps• Summary display and Add • Mail • Safari • <your app>? (probably not)
  13. 13. Companion Apps• YOUR APP• Configure App ID in Provisioning Portal• Generate Provisioning Profiles in Portal (after configuring the App ID)• Configure app Entitlements.plist plus Team ID!
  14. 14. Companion Apps ii• Access YOUR Passes Team ID, certificates• Read from a standard set of properties (text, icon)• Access custom properties by JSON “key”
  15. 15. Companion Apps iii• Companion apps can appear to “generate” Passes • eg. Starbucks app : adds and updates Passes • eg. Collect user data (or payment) in your app, then add a Pass• DO NOT GENERATE PASSES IN APP • It requires your certificates to sign; they should be kept secure • Create your own webservice to deliver the Pass file
  16. 16. Companion Apps iv• A simple PassKit-capable app • reads from the Passbook library DEMO #2Xamarin’s PassKit samplehttps://github.com/xamarin/monotouch-samples/tree/master/PassKit
  17. 17. Scanning Apps• YOUR APP or a Point of Sale system or ???• Only chance to “implement security” (a duplicate Pass is as easy as a screenshot)• Update server in real-time • Can trigger APNS > Pass update (eg. store card balance)
  18. 18. (MonkeyScan & Azure) Scanning Apps ii MonkeyScan sample https://github.com/conceptdev/MonkeySpace/tree/master/iOS.MonkeyScan • Microsoft Azure Mobile Services • Xamarin Client Librarypublic static readonly MobileServiceClient MobileService = new MobileServiceClient (Constants.AzureUrl, Constants.AzureKey);public static readonly IMobileServiceTable<ConfScan> scanTable = MobileService.GetTable<ConfScan>();// then...public TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext();// and then...AzureManager.scanTable.InsertAsync (scan) .ContinueWith (t => { if (t.Status == TaskStatus.RanToCompletion) Console.WriteLine ("Updated scan in cloud " + t.Status + " " + t.Id); else ; // error handling or store and retry... } , scheduler);
  19. 19. (MonkeyScan) Scanning Apps iv• MonkeySpace attendees are on-time!• App has real-time count•
  20. 20. Updates with APNS "webServiceURL" : "https://example.com/passes/","authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc", Apple Scanner push update notification APNS servers Update database P.O.S. notification of change register pass : pushToken dissociate pass web register pass : pushToken service Your certificate for signing passes server sign-pass images and JSON resources used to generate passes Passbook
  21. 21. Updates with APNS ii• REST web service : Apple’s defined format• Register : when pass is added POST webServiceURL/version/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier/serialNumber• pushToken Delete : shredder! DELETE webServiceURL/version/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier/serialNumber• Update : build and send new data (same serial #) GET webServiceURL/version/passes/passTypeIdentifier/serialNumber• Get Serial Numbers for Device GET webServiceURL/version/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier?passesUpdatedSince=tag• Error Logging (optional) POST webServiceURL/version/log
  22. 22. Review Scan Pass push update notification Add Pass Apple APNS servers Passbook Update database Scanner register request notification pass changed of change data P.O.S. generate & sign pass web Your make changes to pass service Add Pass certificate for signing passes server sign-pass images and JSON resources used to generate passesCompanion Apps pass & device Your app database email attachments web links Conduit Mail Safari Apps (others)
  23. 23. Cross-platform? PassWallet for Android (Attido Mobile)• Cross-platform C# library for reading & writing PKPass files https://github.com/Redth/PassKitSharp• Cross-platform C# library for barcode scanning https://github.com/Redth/ZXing.Net.Mobile• Push Notifications C# library for Push Notifications @redth https://github.com/Redth/PushSharp/
  24. 24. finishttp://docs.xamarin.com/ios/Guides/Platform_Features/Introduction_to_PassKit https://github.com/xamarin/monotouch-samples/tree/master/PassKit https://github.com/conceptdev/MonkeySpace/tree/master/iOS.MonkeyScan @conceptdev xamarin.com

×