ios newsstand api n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
iOS Newsstand API PowerPoint Presentation
Download Presentation
iOS Newsstand API

Loading in 2 Seconds...

play fullscreen
1 / 20
kamuzu

iOS Newsstand API - PowerPoint PPT Presentation

164 Views
Download Presentation
iOS Newsstand API
An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. iOS Newsstand API 10/27/2011 – North Atlanta iOS Developers Meetup

  2. How to create Newstand App • Add the following key to your application’s Info.plist file <key>UINewsstandApp</key><true/> Application presents content in Newsstand = YES Believe it or not, that is all that’s needed for an app to be a Newsstand app – and appear in the Newsstand.

  3. Background Downloads • One of the powerful capabilities is for content to be automatically downloaded (over Wifi) – even if your application is not running. • How does iOS Device know that there is new content? Newsstand leverages Push Notification

  4. Push Notification Changes • New Notification type: UIRemoteNotificationTypeNewsstandContentAvailability • Register same way other Push Notification types can be registered

  5. Push Notification Changes • JSON Push Payload – can be combined with other push types { ‘aps’: {‘content-available’: 1 } } • Limited to 1 push per day (for background downloading) – unless NKDontThrottleNewsstandContentNotifications is set to True in User Defaults (for debug/test)

  6. How do I implement Push Notification Server for Newsstand • Urban Airship – Buy their Pro-In app Purchase plan ($499/month). • Create your own server (referring to Apple Docs) • Modify open-source Push Server code (Easy APNS) http://www.easyapns.com/ [This is the route I took. I’ve used this library on other projects, and will inquire about getting my changes merged in].

  7. Downloading Content • When receiving the Push Notification, the iOS Client needs to ask the server (that originated the push) what content is available. • Server should return unique issue name for each issue, publication date, and URL(s) to download content.

  8. Main Classes • NKLibrary - Represents the application’s library of newsstand issues • NKIssue – Represents a publication’s issue in the library • NKAssetDownload – An asset that is to be downloaded (or has downloaded) from the server.

  9. Adding a new Issue • Get NKLibrary instance ([NKLibrarysharedLibrary]) • Invoke addIssueWithName: date: method on Library • Issue Name must be unique to magazine. It’s possible to query Library to see if an issue exists. This is useful if server returns all issues that user is subscribed to.

  10. Downloading Issue Content • Once an Issue has been added, create NSURLRequest(s) for each magazine asset that needs to be downloaded. • Invoke addAssetWithRequest on Issue instance. This returns an NKAssetDownload class that is associated with the issue. • These classes will continue downloading data in the background (if app goes to background)

  11. Downloading Issue Content • New delegate (NSURLConnectionDownloadDelegate) added to notify app when download is finished. • connectionDidFinishDownloading invoked when asset has finished downloading. NSURLConnection class has a new attribute ‘newsstandAssetDownload’ and is passed in URL containing where the file has been downloaded locally.

  12. Downloading Issue Content • Each Issue has a contentURL containing the directory that content for that issue should be written to. • Downloaded file should be copied to Issue’s content directory. • To keep things simple, in my app – I have a single .zip file (1 file downloaded) that contains everything including the Cover image – and unzip everything there. • Calling setNewsstandIconImage on UIApplication updates image in Newsstand. This should be a file you downloaded.

  13. Benefits of Newsstand Framework • Why can’t (or shouldn’t) I write to the Documents directory? Using the Newstand API’s – allows for storage space to be used efficiently across all Newstand Apps – and to automatically free space for older issues that have not recently been read (so we don’t have to manage this in our apps). There’s a mechanism to specify the issue currently being read. • Why an NKAssetDownload class? • Just imagine 100 newstand apps all downloading in the background a the same time.

  14. Additional Download Notes • On App startup, you need to check for files that are downloading (to resume downloading) using newstand API • For background downloading, you need to add ‘newsstand-content’ as a Background mode.

  15. Presenting Content • Now that the content is downloaded, we need to display it. • The Newsstand API does not provide anything here. What can be achieved is only limited by your imagination. • The Content presentation could be as simple as a single UIWebView – or it could be a custom UI (ie. Daily Sudoku magazine – with a different puzzle). • There should be a UI mechanism to allow for issues to be browsed (and possibly purchased using in-app purchase)

  16. Presenting Content • Nothing free/open-source exists that addresses all of these, but Laker (which allows for a single magazine to be displayed with swiping) – is . Content of magazine is HTML 5 Available at: http://www.lakercompendium.com/

  17. Additional Resources • 2011 WWDC Presentations on Newsstand API (available if member of iOS Developer Program) • Newstand for Developers https://developer.apple.com/devcenter/ios/newsstand/

  18. Building on code presented to have an iOS Developers Magazine • Need person(s) with artistic skills to create Application Icon as well as Magazine icon (hopefully something that can easily be changed by – changing a layer in Photoshop). • Need to modify Laker code, such that it can use the content that is downloaded when selecting the issue. • Need to tweak UI such that covers of magazine are displayed better (maybe a view where you can swipe through them) – and to have a way when viewing an issue to change magazine

  19. Building on code presented to have an iOS Developers Magazine • Need writer(s)/author(s) to contribute articles to the magazine. • Need editor(s) to both review as well as format articles using HTML5 (and Laker tags) • Add in-app subscription capability / Server mechanism to keep track of users (maybe it would be useful to know who is subscribing – email address OR to further segment content – ie. a magazine that tailored content locally (think school magazine – where last page was page for student’s class)

  20. Building on code presented to have an iOS Developers Magazine • Goal is to eventually have a free open platform that can be used by entities (non-profit / profit) that can’t afford to pay Adobe $5000+ / year.