Building newsstand_apps
Upcoming SlideShare
Loading in...5
×
 

Building newsstand_apps

on

  • 1,494 views

How to develop nice magazines to newsstand of Apple...

How to develop nice magazines to newsstand of Apple...

Statistics

Views

Total Views
1,494
Views on SlideShare
1,494
Embed Views
0

Actions

Likes
1
Downloads
26
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Building newsstand_apps Building newsstand_apps Presentation Transcript

  • Building Newsstand AppsSession 504Ben NielseniOS Application EngineeringThese are confidential sessions—please refrain from streaming, blogging, or taking pictures 1
  • 2
  • 3
  • 4
  • 5
  • 222 6
  • NewsstandThe look 7
  • NewsstandThe look • Repository for publications • Richer visual experience • Icons reflect content • iTunes Store integration 8
  • NewsstandKit Your App • Push notification updates NewsstandKit UIKit NKLibrary • Content organization NKIssue NKAssetDownload Foundation • Background downloads 9
  • What You’ll Learn• Appearing in Newsstand• Retrieving content• Presenting content 10
  • Appearing in NewsstandJon DrummondiOS Application Engineering 11
  • Appearing in NewsstandBecoming a Newsstand app• Add one key to your Info.plist <key>UINewsstandApp</key> <true/>• You’re now a Newsstand app!• But you need an icon… 12
  • Appearing in NewsstandTime for an icon• One icon style in iOS 4 ■ Home screen ■ Search ■ Settings ■ App switcher ■ Notifications 13
  • 14
  • Appearing in NewsstandNewsstand icons• Distinct from standard app icons ■ Home screen and app switcher• Should reflect your content• Dynamic—can be updated after your app is installed• Additional adornment for magazine and newspaper styles 15
  • Appearing in NewsstandStandard icons• We still need them! ■ Settings, Search, Notifications…• Newsstand icon must be defined in addition to the standard icon 16
  • Appearing in NewsstandStandard icon specification• Top-level key in your Info.plist with an array of image names <key>CFBundleIconFiles</key> <array> ! <string>Icon.png</string> ! <string>Icon@2x.png</string> ... </array> 17
  • Appearing in NewsstandNewsstand icons• A new top-level Info.plist key ■ CFBundleIcons—a dictionary of icon styles CFBundlePrimaryIcon UINewsstandIcon 18
  • Appearing in Newsstand Updating your Info.plist <key>CFBundleIcons</key> New top-level key <dict> <key>CFBundlePrimaryIcon</key> Icon style key <dict> <key>CFBundleIconFiles</key> <array>Existing CFBundleIconFiles <string>Icon.png</string> <string>Icon@2x.png</string> </array> </dict> </dict> 19
  • Appearing in Newsstand Updating your Info.plist <key>CFBundleIcons</key> New top-level key <dict> <key>CFBundlePrimaryIcon</key> Icon style key <dict>...</dict> <dict> <key>CFBundleIconFiles</key> <array>Existing CFBundleIconFiles <string>Icon.png</string> <string>Icon@2x.png</string> </array> </dict> </dict> 20
  • Appearing in NewsstandCustomizing your Newsstand icon• Icons are adorned to resemble their physical counterparts ■ Newspaper or magazine? ■ Binding edge• Exist as keys inside the UINewsstandIcon style dictionary 21
  • Appearing in NewsstandCustomizing your Newsstand icon UINewsstandBindingTypeMagazine UINewsstandBindingTypeNewspaper StackStaples Pages Fold UINewsstandBindingEdgeLeft UINewsstandBindingEdgeRight UINewsstandBindingEdgeBottom 22
  • Appearing in NewsstandUpdating your Info.plist <key>CFBundleIcons</key><dict> <key>UINewsstandIcon</key><dict> Newsstand style <key>CFBundleIconFiles</key>...</array> key and icon files <key>UINewsstandBindingType</key> <string>UINewsstandBindingTypeNewspaper</string> Options <key>UINewsstandBindingEdge</key> <string>UINewsstandBindingEdgeBottom</string> </dict> </dict> 23
  • Appearing in NewsstandAdditional considerations• Icons need not be square ■ Use a shape that matches your physical appearance• You must still include CFBundlePrimaryIcon ■ Standard and Newsstand icon are both needed• Backward compatibility ■ CFBundleIcons is required for Newsstand apps in iOS 5 ■ Can coexist with existing icon keys for earlier versions of iOS 24
  • DemoCreating a Newsstand App 25
  • Handling UpdatesBen NielseniOS Application Engineering 26
  • Handling UpdatesRetrieving and presenting content• Informing the app INFORMING• Organizing issues• Downloading content UPDATING ORGANIZING• Updating your icon DOWNLOADING 27
  • Handling UpdatesInforming the App 28
  • INFORMINGInforming the App UPDATING ORGANIZING Push notifications DOWNLOADING 29
  • INFORMINGInforming the App UPDATING ORGANIZINGNewsstand Push Notifications DOWNLOADING• Registration Type UIRemoteNotificationTypeNewsstandContentAvailability• Payload Key { ‘aps’:{ ‘content-available’:1 } }• Once per day ■ NSUserDefaults: @”NKDontThrottleNewsstandContentNotifications” 30
  • INFORMINGInforming the App UPDATING ORGANIZINGNewsstand Push Notifications DOWNLOADING• Background mode <key>UIBackgroundModes</key> <array> <string>newsstand-content</string> </array>• Limited time -[UIApplication beginTaskWithExpirationHandler:] 31
  • Handling UpdatesOrganizing issues 32
  • INFORMINGOrganizing Issues UPDATING ORGANIZINGUsing NKLibrary DOWNLOADING• Provides persistent state for: ■ Available issues ■ Ongoing downloads ■ Issue being read• Organizes issues ■ Uses app’s Caches directory ■ Improves resource management 33
  • INFORMINGOrganizing Issues UPDATING ORGANIZINGNKIssues DOWNLOADING• Creating issues ■ Unique name ■ Publication date NKIssue *myIssue = [myLibrary addIssueWithName:issueName date:issueDate]; ■ Maintains a repository within the library NSURL *baseURL = [myIssue contentURL];• Setting the current issue [myLibrary setCurrentlyReadingIssue:myIssue]; 34
  • Handling UpdatesDownloading content 35
  • INFORMINGDownloading Content UPDATING ORGANIZINGNKAssetDownload DOWNLOADING• Handles data transfer ■ Keeps going• Uses NSURLConnectionDelegate• Wake for critical events newsstand-content• Wi-Fi only in background 36
  • INFORMINGDownloading Content UPDATING ORGANIZINGSetup DOWNLOADINGNSArray *itemsToDownload = !! query server for list of assetsfor (item in itemsToDownload) { NSURLRequest *downloadRequest = [item URLRequest]; NKAssetDownload *asset = [issue addAssetWithRequest:downloadRequest]; NSURLConnection *connection = [asset downloadWithDelegate:myDelegate];} 37
  • INFORMINGDownloading Content UPDATING ORGANIZINGNSURLConnectionDownloadDelegate DOWNLOADING [asset downloadWithDelegate:myDelegate];• Implements NSURLConnectionDelegate ■ Status ■ Authentication ■ Completion• Modifications -connection:didReceiveData: 38
  • INFORMINGDownloading Content UPDATING ORGANIZINGNSURLConnectionDownloadDelegate DOWNLOADING [asset downloadWithDelegate:myDelegate];• Implements NSURLConnectionDelegate ■ Status ■ Authentication ■ Completion• Modifications -connection:didWriteData:totalBytesWritten:expectedTotalBytesWritten: -connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytesWritten: -connectionDidFinishLoading: 39
  • INFORMINGDownloading Content UPDATING ORGANIZINGNSURLConnectionDownloadDelegate DOWNLOADING [asset downloadWithDelegate:myDelegate];• Implements NSURLConnectionDelegate ■ Status ■ Authentication ■ Completion• Modifications -connection:didWriteData:totalBytesWritten:expectedTotalBytesWritten: -connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytesWritten: -connectionDidFinishDownloading:destinationURL: required 40
  • INFORMINGDownloading Content UPDATING ORGANIZINGBackground DOWNLOADING• What if the app is suspended? ■ No status updates ■ Wakes for authentication and completion• What if the app is terminated!? ■ Relaunched in the background UIApplicationLaunchOptionsNewsstandDownloadsKey NSString *assetIdentifier = [myAssetDownload identifier]; 41
  • INFORMINGDownloading Content UPDATING ORGANIZINGReconnecting DOWNLOADING• Reconnect on launch NKLibrary *library = [NKLibrary sharedLibrary]; for (NKAssetDownload *asset in [library downloadingAssets]) NSURLConnection *connection = [asset downloadWithDelegate:myDelegate];• Always! ■ Abandoned downloads may get cancelled 42
  • INFORMINGDownloading Content UPDATING ORGANIZINGCompletion DOWNLOADING• Success! -connectionDidFinishDownloading:destinationURL: ■ Destination is a temporary file ■ Move to issue repository [myIssue contentURL] ■ Process -[UIApplication beginTaskWithExpirationHandler:]; 43
  • DemoDownloading content 44
  • Updating Your Newsstand IconJon Drummond 45
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZINGShowing off your new content DOWNLOADING• Part of getting new content is obtaining a new icon• Once content is ready to view, show it off! ■ Update your Newsstand icon ■ Inform readers of new issues via badging June 2011 May 2011 46
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZINGUpdate your icon DOWNLOADING• Publication covers play a huge role in the physical newsstand ■ We want your icons to do the same here• Your icon should represent your most recent content ■ But don’t show it until your content is ready to read!• Changes the appearance of your app in Newsstand and app switcher ■ Overrides your UINewsstandIcon, not your standard app icon 47
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZINGUpdate your icon DOWNLOADING• Simple! -[UIApplication setNewsstandIconImage:(UIImage*)]• Can be used while running in the background, so update whenever your content is ready 48
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZINGBadge your app DOWNLOADING• Badges in Newsstand have a revised look: “New” sash• Add a badge when a user has not yet opened a particular issue ■ Remove the badge once it has been read 49
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZINGBadge your app DOWNLOADING• Uses existing badge API -[UIApplication setApplicationIconBadgeNumber:(NSInteger)]• As with normal badging... ■ Non-zero value shows the sash ■ Zero clears the sash• The count is not shown, but it should track your unread issues 50
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZING DOWNLOADING- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL {} 51
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZING DOWNLOADING- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL { // get issue content location NKIssue *latestIssue = [[connection newsstandAssetDownload] issue]; NSURL *issueURL = [[latestIssue contentURL] URLByAppendingPathComponent:...];} 52
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZING DOWNLOADING- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL { // get issue content location NKIssue *latestIssue = [[connection newsstandAssetDownload] issue]; NSURL *issueURL = [[latestIssue contentURL] URLByAppendingPathComponent:...]; // move issue into place -- don’t forget to check errors! NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager moveItemAtURL:destinationURL toURL:issueURL error:NULL];} 53
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZING DOWNLOADING- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL { // get issue content location NKIssue *latestIssue = [[connection newsstandAssetDownload] issue]; NSURL *issueURL = [[latestIssue contentURL] URLByAppendingPathComponent:...]; // move issue into place -- don’t forget to check errors! NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager moveItemAtURL:destinationURL toURL:issueURL error:NULL]; // get our new icon and update our app! UIImage *newIcon = [self getIconFromIssue:latestIssue]; // up to you} 54
  • INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZING DOWNLOADING- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL { // get issue content location NKIssue *latestIssue = [[connection newsstandAssetDownload] issue]; NSURL *issueURL = [[latestIssue contentURL] URLByAppendingPathComponent:...]; // move issue into place -- don’t forget to check errors! NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager moveItemAtURL:destinationURL toURL:issueURL error:NULL]; // get our new icon and update our app! UIImage *newIcon = [self getIconFromIssue:latestIssue]; // up to you UIApplication *app = [UIApplication sharedApplication]; [app setNewsstandIconImage:newIcon]; [app setApplicationIconBadgeNumber:[app applicationIconBadgeNumber]+1];} 55
  • DemoUpdating your Newsstand icon 56
  • Summary• Becoming a Newsstand app is easy• Get content updates in the background• Use NewsstandKit to download and organize content• Update your Newsstand icon and badge to show off your content 57
  • More InformationVicki MurleySafari Technology Evangelistvicki@apple.com 58
  • Related Sessions PresidioApp Publishing with iTunes Connect Thursday 10:15AM Pacific HeightsLocal and Push Notifications Thursday 4:30PM Russian HillAdopting Multitasking Thursday 4:30PM 59
  • Labs Internet & Web Lab BNewsstand Lab Thursday 2:00PM Internet & Web Lab AApp Publishing with iTunes Connect Lab Thursday 2:00PM Internet & Web Lab ALocal and Push Notifications Lab Friday 9:00AM 60
  • Q&A 61
  • 62