Building newsstand_apps

  • 1,274 views
Uploaded on

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

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

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,274
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
27
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Building Newsstand AppsSession 504Ben NielseniOS Application EngineeringThese are confidential sessions—please refrain from streaming, blogging, or taking pictures 1
  • 2. 2
  • 3. 3
  • 4. 4
  • 5. 5
  • 6. 222 6
  • 7. NewsstandThe look 7
  • 8. NewsstandThe look • Repository for publications • Richer visual experience • Icons reflect content • iTunes Store integration 8
  • 9. NewsstandKit Your App • Push notification updates NewsstandKit UIKit NKLibrary • Content organization NKIssue NKAssetDownload Foundation • Background downloads 9
  • 10. What You’ll Learn• Appearing in Newsstand• Retrieving content• Presenting content 10
  • 11. Appearing in NewsstandJon DrummondiOS Application Engineering 11
  • 12. 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
  • 13. Appearing in NewsstandTime for an icon• One icon style in iOS 4 ■ Home screen ■ Search ■ Settings ■ App switcher ■ Notifications 13
  • 14. 14
  • 15. 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
  • 16. Appearing in NewsstandStandard icons• We still need them! ■ Settings, Search, Notifications…• Newsstand icon must be defined in addition to the standard icon 16
  • 17. 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
  • 18. Appearing in NewsstandNewsstand icons• A new top-level Info.plist key ■ CFBundleIcons—a dictionary of icon styles CFBundlePrimaryIcon UINewsstandIcon 18
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. Appearing in NewsstandCustomizing your Newsstand icon UINewsstandBindingTypeMagazine UINewsstandBindingTypeNewspaper StackStaples Pages Fold UINewsstandBindingEdgeLeft UINewsstandBindingEdgeRight UINewsstandBindingEdgeBottom 22
  • 23. 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
  • 24. 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
  • 25. DemoCreating a Newsstand App 25
  • 26. Handling UpdatesBen NielseniOS Application Engineering 26
  • 27. Handling UpdatesRetrieving and presenting content• Informing the app INFORMING• Organizing issues• Downloading content UPDATING ORGANIZING• Updating your icon DOWNLOADING 27
  • 28. Handling UpdatesInforming the App 28
  • 29. INFORMINGInforming the App UPDATING ORGANIZING Push notifications DOWNLOADING 29
  • 30. INFORMINGInforming the App UPDATING ORGANIZINGNewsstand Push Notifications DOWNLOADING• Registration Type UIRemoteNotificationTypeNewsstandContentAvailability• Payload Key { ‘aps’:{ ‘content-available’:1 } }• Once per day ■ NSUserDefaults: @”NKDontThrottleNewsstandContentNotifications” 30
  • 31. INFORMINGInforming the App UPDATING ORGANIZINGNewsstand Push Notifications DOWNLOADING• Background mode <key>UIBackgroundModes</key> <array> <string>newsstand-content</string> </array>• Limited time -[UIApplication beginTaskWithExpirationHandler:] 31
  • 32. Handling UpdatesOrganizing issues 32
  • 33. 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
  • 34. 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
  • 35. Handling UpdatesDownloading content 35
  • 36. INFORMINGDownloading Content UPDATING ORGANIZINGNKAssetDownload DOWNLOADING• Handles data transfer ■ Keeps going• Uses NSURLConnectionDelegate• Wake for critical events newsstand-content• Wi-Fi only in background 36
  • 37. 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
  • 38. INFORMINGDownloading Content UPDATING ORGANIZINGNSURLConnectionDownloadDelegate DOWNLOADING [asset downloadWithDelegate:myDelegate];• Implements NSURLConnectionDelegate ■ Status ■ Authentication ■ Completion• Modifications -connection:didReceiveData: 38
  • 39. INFORMINGDownloading Content UPDATING ORGANIZINGNSURLConnectionDownloadDelegate DOWNLOADING [asset downloadWithDelegate:myDelegate];• Implements NSURLConnectionDelegate ■ Status ■ Authentication ■ Completion• Modifications -connection:didWriteData:totalBytesWritten:expectedTotalBytesWritten: -connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytesWritten: -connectionDidFinishLoading: 39
  • 40. 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
  • 41. 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
  • 42. 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
  • 43. INFORMINGDownloading Content UPDATING ORGANIZINGCompletion DOWNLOADING• Success! -connectionDidFinishDownloading:destinationURL: ■ Destination is a temporary file ■ Move to issue repository [myIssue contentURL] ■ Process -[UIApplication beginTaskWithExpirationHandler:]; 43
  • 44. DemoDownloading content 44
  • 45. Updating Your Newsstand IconJon Drummond 45
  • 46. 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
  • 47. 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
  • 48. 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
  • 49. 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
  • 50. 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
  • 51. INFORMINGUpdating Your Newsstand Icon UPDATING ORGANIZING DOWNLOADING- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL {} 51
  • 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:...];} 52
  • 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];} 53
  • 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} 54
  • 55. 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
  • 56. DemoUpdating your Newsstand icon 56
  • 57. 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
  • 58. More InformationVicki MurleySafari Technology Evangelistvicki@apple.com 58
  • 59. 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
  • 60. 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
  • 61. Q&A 61
  • 62. 62