Follow
Publications: 43 | Followers: 0

iOS Newsstand API - files.meetup.com

Publish on Category: Birds 0

iOS Newsstand API
10/27/2011 – North Atlanta iOS DevelopersMeetup
How to createNewstandApp
Add the following key to your application’sInfo.plistfile<key>UINewsstandApp</key><true/>Application presents content in Newsstand = YESBelieve it or not, that is all that’s needed for an app to be a Newsstand app – and appear in the Newsstand.
Background Downloads
One of the powerful capabilities is for content to be automatically downloaded (overWifi) – even if your application is not running.How does iOS Device know that there is new content? Newsstand leverages Push Notification
Push Notification Changes
New Notification type:UIRemoteNotificationTypeNewsstandContentAvailabilityRegister same way other Push Notification types can be registered
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) – unlessNKDontThrottleNewsstandContentNotificationsis set to True in User Defaults (for debug/test)
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].
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.
Main Classes
NKLibrary- Representsthe application’s library of newsstandissuesNKIssue– Represents a publication’s issue in the libraryNKAssetDownload– An asset that is to be downloaded (or has downloaded) from the server.
Adding a new Issue
GetNKLibraryinstance ([NKLibrarysharedLibrary])InvokeaddIssueWithName: date: method on LibraryIssue 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.
Downloading Issue Content
Once an Issue has been added, createNSURLRequest(s) for each magazine asset that needs to be downloaded.InvokeaddAssetWithRequeston Issue instance. This returns anNKAssetDownloadclass that is associated with the issue.These classes will continue downloading data in the background (if app goes to background)
Downloading Issue Content
New delegate (NSURLConnectionDownloadDelegate) added to notify app when download is finished.connectionDidFinishDownloadinginvoked when asset has finished downloading.NSURLConnectionclass has a new attribute ‘newsstandAssetDownload’ and is passed in URL containing where the file has been downloaded locally.
Downloading Issue Content
Each Issue has acontentURLcontaining 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.CallingsetNewsstandIconImageonUIApplicationupdates image in Newsstand. This should be a file you downloaded.
Benefits of Newsstand Framework
Why can’t (or shouldn’t) I write to the Documents directory?Using theNewstandAPI’s – allows for storage space to be used efficiently across allNewstandApps – 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 anNKAssetDownloadclass?Just imagine 100newstandapps all downloading in the background a the same time.
Additional Download Notes
On App startup, you need to check for files that are downloading (to resume downloading) usingnewstandAPIFor background downloading, you need to add ‘newsstand-content’ as a Background mode.
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 singleUIWebView– 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)
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 5Available at:http://www.lakercompendium.com/
Additional Resources
2011 WWDC Presentations on Newsstand API (available if member of iOS Developer Program)Newstandfor Developershttps://developer.apple.com/devcenter/ios/newsstand/
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
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)
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) thatcan’t afford to pay Adobe $5000+ / year.

0

Embed

Share

Upload

Make amazing presentation for free
iOS Newsstand API - files.meetup.com