SlideShare una empresa de Scribd logo
1 de 46
Descargar para leer sin conexión
Newsstand
  Kaz Yoshikawa
Why Newsstand?

•   Contents can be delivered to devices while sleeping
    •   background downloading
•   Good for subscription type business model
    •   Magazines, Newspaper, Free papers ...
How Newsstand Work?
④ Launch with                                                    Your Server
Background mode                                     ① Launch Time
                                                    Device Token, etc.
                                           ⑤ Download Contents

                                                 Contents
                                                                         SSL
                                     ② When New Issue is Ready           Certificate
                                                       Device Token
                ⑥ Enjoy Reading Contents

       ③ Push Notification
                                                             Apple’s APNS
Requirements (Vender)
•   Server facility
    •   Hosting contents for downloading:
        •   Capable of simultaneous download requests
    •   Push Notifications
        •   Server side programming: i.e. Apache+MySQL+PHP
        •   SSL Certificate *
Provisioning Portal
       Paper Work
New App ID
Enable Push Notification
Register SSL Certificate
Provisioning Profiles
•   Push Notification won’t work on Wildcard provisioning
iTunes Connect
   Another Paper Work
Add New App from ITC


•   In-App-Purchase can only be
    configured from iTunesConnect
•
In-App Purchases
In-App Purchases




               Auto-Renewable

               Free Subscription
Add Duration and Pricing


                    Duration

                    Sale or not
                    Price Tier
Adding a Language
In-App Purchases
Shared Secret
Enabling Newsstand
Issues
Issue Added
ATOM Feed
•   Apple’s server checks your new issues time to time to
    update iTunesConnect.
Xcode
Info plist
Register Remote Notification
  - (BOOL)application:(UIApplication *)application
  didFinishLaunchingWithOptions:(NSDictionary *)options
{
! // ...
! UIRemoteNotificationType type =
           UIRemoteNotificationTypeBadge |
! ! ! ! UIRemoteNotificationTypeSound |
! ! ! ! UIRemoteNotificationTypeAlert |
           UIRemoteNotificationTypeNewsstandContentAvailability;
! [[UIApplication sharedApplication]
          registerForRemoteNotificationTypes:type];
}
Newsstand Notification
•   Receive remote notification only once a day
    •   You cannot push two contents a day
•   You can push regular push notifications multiple time
•   For debuging:
    [[NSUserDefaults standardUserDefaults] setValue:@YES
        forKey:@"NKDontThrottleNewsstandContentNotifications"];
Send Token To Your Server
        with APS Environment
- (void)application:(UIApplication *)application
   didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token
{
#if DEBUG
! NSString *aps_environment = @"development";      Why?
#else
! NSString *aps_environment = @"production";
#endif
! // send token to your server with other properties aps_environment
}
Different Token:
             Development/Production

       Debug                            Release

                                                                 APNS
                                                  production
                                                                  Sandbox
                     development


    app_id           token       environment

com.electricwoo
                  0x123...af30   development    Your
ds.yourmagazine
com.electricwoo
                  0x5c6...78c1    production   Server            APNS
ds.yourmagazine                                                Production
Downloading New Issue
                                                       Your Server
APNS     ① Push Notification      ② Query Issues

{                              Issue name, Published date, Download URL
  "aps":{
! "content-available":1,
        },                      ③ Download new Issue
  ...
}
          Payload
                                            ④ Unzip* and move
    ⑤ Replace Newsstand Icon


                                                               * optional
Downloading New Issue
- (void)downloadContentName:(NSString *)name
        URL:(NSURL *)URL date:(NSDate *)date
{
    NKLibrary *lib = [NKLibrary sharedLibrary];
    NKIssue *issue = [lib issueWithName:name];
    if (!issue) {
        issue = [lib addIssueWithName:name date:date];
        NKAssetDownload *download = [issue addAssetWithRequest:
            [NSURLRequest requestWithURL:URL]];
        [download downloadWithDelegate:self];
    }
}

- (void)connectionDidFinishDownloading:(NSURLConnection *)connection
    destinationURL:(NSURL *)destinationURL
{
!   NSIssue *issue = connection.newsstandAssetDownload.issue;
    NSString *contentPath = issue.contentURL.path;
    // unzip destinationURL to contentPath
}
Restore Downloads
                at Launch Time
!
                                                       Don’t forget


  NKLibrary *library = [NKLibrary sharedLibrary];
! for (NKAssetDownload *download in library.downloadingAssets) {
! ! [download downloadWithDelegate:self];
! }
Making a list of Issues
NKLibrary *lib = [NKLibrary sharedLibrary];
NSArray *issues = [lib issues];




                                    Build a Great
                                     Bookshelf
In App Purchase
Auto-renewable Subscription
•   Newsstand App requires at least one Auto-renewable
    subscription or free subscription
•   Auto-renewable durations are: 7d, 1m, 2m, 3m, 6m, 1y
•   StoreKit won’t let app know duration from product
    identifier
    •   Need to query to your server or hard-coded
Restore Problem
•   What if Someone purchased auto-renewable
    subscriptions in-and-out few times
•   Purchased records can be retrieved by restore operation
•   But it can be cancelled, and StoreKit wouldn’t tell me...
•   Needs to ask to Apple’s server to verify those purchases



Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Verifying Receipt
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue
*)queue
! for (SKPaymentTransaction *transaction in queue.transactions) {
! ! NSString *identifier = transaction.payment.productIdentifier;
! ! switch (transaction.transactionState) {
! ! case SKPaymentTransactionStatePurchasing: // ...
! ! case SKPaymentTransactionStateFailed: // ...

!   !   case SKPaymentTransactionStatePurchased:
!   !   case SKPaymentTransactionStateRestored:
!   !   ! [self verifyTransactionReceipt:transaction];
!   !   ! break;
!   !   }
!   }
}

- (void)verifyTransactionReceipt:(SKPaymentTransaction *)transaction
{
   ... do your stuff ...
   [queue finishTransaction:transaction];
}
DEBUG
                   Verifying Receipts
                                                                               App Store
                                                                                 Production
         {
              "receipt-data" : "(receipt bytes here)",
              "sandbox"      : 1
         }




         {
           "status" : 0,
           "receipt" : ,
           "latest_receipt" : ...      {
   0       "latest_receipt_info" : ...   "receipt-data" : "(receipt bytes here)",
         }                               "password"     : "(shared secret bytes here)"
  OK                                   }

                                                                                          Sandbox
                                             {
                                                 "status" : 0,
                                                                                   App Store
Your Server                                      "receipt" : { (receipt here) },
                                                 "latest_receipt" : "(base-64 encoded receipt here
                                                 "latest_receipt_info" : { (latest receipt info here
                                             }
PRODUCTION
                   Verifying Receipts
                                                                                App Store
                                                                                  Production
                                                         {
          {
                                                             "receipt-data" : "(receipt bytes here)",
              "receipt-data" : "(receipt bytes here)",
                                                             "password"     : "(shared secret bytes he
          }
                                                         }


                                                         {
                                                             "status" : 21006,
          {                                                  "receipt" : { (receipt here) },
              "status" : 21006,                              "latest_receipt" : "(base-64 encoded re
              "receipt" : ,                                  "latest_receipt_info" : { (latest receip
              "latest_receipt" : ...                     }
21006         "latest_receipt_info" : ...
          }
expired
                                                                                            Sandbox
                                                                                     App Store
Your Server
Auto renewable subscription
     recurring duration
           Production         Sandbox
             1 week           3 minutes
            1 month           5 minutes
            2 months         10 minutes
            3 months         15 minutes
            6 months         30 minutes
             1 year            1 hour

    Automatically expires in 6th time recurring
"receipt" :{
                        Not Expired                             "receipt":{
                                                                                         Expired
      "unique_identifier":"44f9ec48b952a....34e12c61c9c4f",            "unique_identifier":"44f9ec48b952a....34e12c61c9c4f",
      "original_transaction_id":"1000000055744550",                   "original_transaction_id":"1000000055744550",
      "expires_date":"1348131173000",                                 "expires_date":"1347344399000",
      "transaction_id":"1000000056135747",                            "transaction_id":"1000000055932398",
      "quantity":"1",                                                 "quantity":"1",
      "product_id":"yourmagazine.1mo",                                "product_id":"yourmagazine.1mo",
      "original_purchase_date_ms":"1347343199000",                    "original_purchase_date_ms":"1347343199000",
      "bid":"com.electricwoods.newsstand",                            "bid":"com.electricwoods.newsstand",
      "bvrs":"1.0",                                                   "bvrs":"1.0",
      "expires_date_formatted":"2012-09-20 08:52:53 Etc/GMT",         "expires_date_formatted":"2012-09-11 06:19:59 Etc/GMT",
      "purchase_date":"2012-09-20 08:47:53 Etc/GMT",                  "purchase_date":"2012-09-11 06:14:59 Etc/GMT",
      "purchase_date_ms":"1348130873000",                             "purchase_date_ms":"1347344099000",
      "original_purchase_date":"2012-09-11 05:59:59 Etc/GMT",         "original_purchase_date":"2012-09-11 05:59:59 Etc/GMT",
      "item_id":"558725164",                                          "item_id":"558725164"
};                                                              },
“status”: 0                                                     "status":21006
Wrap Up
These are what you get

           Newsstand



                       Push Notification

 In App
Purchase
                                          UIKit
This is what you gonna build
kyoshikawa@electricwoods.com




              Thank you
                    Electricwoods LLC

Más contenido relacionado

Destacado

Basic shooting schedule
Basic shooting scheduleBasic shooting schedule
Basic shooting schedule
11187AJ
 
нескучная презентация
нескучная презентациянескучная презентация
нескучная презентация
TatyanaSannikova
 
365Hangers_Lifestyle
365Hangers_Lifestyle365Hangers_Lifestyle
365Hangers_Lifestyle
365Hangers
 
Presentació
PresentacióPresentació
Presentació
ESO1
 
Основная позиция пальцев на клавиатуре
Основная позиция пальцев на клавиатуреОсновная позиция пальцев на клавиатуре
Основная позиция пальцев на клавиатуре
марина маслова
 
Aplazamiento de sanción en casos de it si la empresa
Aplazamiento de sanción en casos de it si la empresaAplazamiento de sanción en casos de it si la empresa
Aplazamiento de sanción en casos de it si la empresa
R R.
 
Music questionaire
Music questionaireMusic questionaire
Music questionaire
cat663
 

Destacado (20)

Programming Complex Algorithm in Swift
Programming Complex Algorithm in SwiftProgramming Complex Algorithm in Swift
Programming Complex Algorithm in Swift
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
 
Programming Language Swift Overview
Programming Language Swift OverviewProgramming Language Swift Overview
Programming Language Swift Overview
 
Extracting text from PDF (iOS)
Extracting text from PDF (iOS)Extracting text from PDF (iOS)
Extracting text from PDF (iOS)
 
TizenLog.pl: In App Purchase
TizenLog.pl: In App PurchaseTizenLog.pl: In App Purchase
TizenLog.pl: In App Purchase
 
The Power Of In-App Purchases
The Power Of In-App PurchasesThe Power Of In-App Purchases
The Power Of In-App Purchases
 
In-App Purchase
In-App PurchaseIn-App Purchase
In-App Purchase
 
IAP introduce@myBook
IAP introduce@myBook IAP introduce@myBook
IAP introduce@myBook
 
O universo
O universoO universo
O universo
 
Basic shooting schedule
Basic shooting scheduleBasic shooting schedule
Basic shooting schedule
 
Serious Games + Learning Science = Win: How to Teach Product Knowledge, Polic...
Serious Games + Learning Science = Win: How to Teach Product Knowledge, Polic...Serious Games + Learning Science = Win: How to Teach Product Knowledge, Polic...
Serious Games + Learning Science = Win: How to Teach Product Knowledge, Polic...
 
Treball religió
Treball religióTreball religió
Treball religió
 
Trabajo taller
Trabajo tallerTrabajo taller
Trabajo taller
 
профи звук
профи звукпрофи звук
профи звук
 
нескучная презентация
нескучная презентациянескучная презентация
нескучная презентация
 
365Hangers_Lifestyle
365Hangers_Lifestyle365Hangers_Lifestyle
365Hangers_Lifestyle
 
Presentació
PresentacióPresentació
Presentació
 
Основная позиция пальцев на клавиатуре
Основная позиция пальцев на клавиатуреОсновная позиция пальцев на клавиатуре
Основная позиция пальцев на клавиатуре
 
Aplazamiento de sanción en casos de it si la empresa
Aplazamiento de sanción en casos de it si la empresaAplazamiento de sanción en casos de it si la empresa
Aplazamiento de sanción en casos de it si la empresa
 
Music questionaire
Music questionaireMusic questionaire
Music questionaire
 

Similar a Newsstand

vpn router Mikrotik
vpn router Mikrotikvpn router Mikrotik
vpn router Mikrotik
todangkhoa
 

Similar a Newsstand (20)

(ARC401) Cloud First: New Architecture for New Infrastructure
(ARC401) Cloud First: New Architecture for New Infrastructure(ARC401) Cloud First: New Architecture for New Infrastructure
(ARC401) Cloud First: New Architecture for New Infrastructure
 
How to build a server and a iPhone client application using the Apple Push No...
How to build a server and a iPhone client application using the Apple Push No...How to build a server and a iPhone client application using the Apple Push No...
How to build a server and a iPhone client application using the Apple Push No...
 
DevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office HoursDevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office Hours
 
Service Delivery Assembly Line with Vagrant, Packer, and Ansible
Service Delivery Assembly Line with Vagrant, Packer, and AnsibleService Delivery Assembly Line with Vagrant, Packer, and Ansible
Service Delivery Assembly Line with Vagrant, Packer, and Ansible
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
 
Scale Your Data Tier With Windows Server App Fabric
Scale Your Data Tier With Windows Server App FabricScale Your Data Tier With Windows Server App Fabric
Scale Your Data Tier With Windows Server App Fabric
 
Cloud Native Identity with SPIFFE
Cloud Native Identity with SPIFFECloud Native Identity with SPIFFE
Cloud Native Identity with SPIFFE
 
Getting Started with AWS IoT
Getting Started with AWS IoTGetting Started with AWS IoT
Getting Started with AWS IoT
 
Orion Context Broker
Orion Context Broker Orion Context Broker
Orion Context Broker
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
vpn router Mikrotik
vpn router Mikrotikvpn router Mikrotik
vpn router Mikrotik
 
Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)
 
Istio Playground
Istio PlaygroundIstio Playground
Istio Playground
 
Automating Security in your IaC Pipeline
Automating Security in your IaC PipelineAutomating Security in your IaC Pipeline
Automating Security in your IaC Pipeline
 
Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aop
 
Packer, where DevOps begins
Packer, where DevOps beginsPacker, where DevOps begins
Packer, where DevOps begins
 
Parse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & TricksParse London Meetup - Cloud Code Tips & Tricks
Parse London Meetup - Cloud Code Tips & Tricks
 
Windows Azure: Connecting the Dots for a Mobile Workforce
Windows Azure: Connecting the Dots for a Mobile WorkforceWindows Azure: Connecting the Dots for a Mobile Workforce
Windows Azure: Connecting the Dots for a Mobile Workforce
 
Small Python Tools for Software Release Engineering
Small Python Tools for Software Release EngineeringSmall Python Tools for Software Release Engineering
Small Python Tools for Software Release Engineering
 
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Newsstand

  • 1. Newsstand Kaz Yoshikawa
  • 2. Why Newsstand? • Contents can be delivered to devices while sleeping • background downloading • Good for subscription type business model • Magazines, Newspaper, Free papers ...
  • 3. How Newsstand Work? ④ Launch with Your Server Background mode ① Launch Time Device Token, etc. ⑤ Download Contents Contents SSL ② When New Issue is Ready Certificate Device Token ⑥ Enjoy Reading Contents ③ Push Notification Apple’s APNS
  • 4. Requirements (Vender) • Server facility • Hosting contents for downloading: • Capable of simultaneous download requests • Push Notifications • Server side programming: i.e. Apache+MySQL+PHP • SSL Certificate *
  • 5. Provisioning Portal Paper Work
  • 9. Provisioning Profiles • Push Notification won’t work on Wildcard provisioning
  • 10. iTunes Connect Another Paper Work
  • 11. Add New App from ITC • In-App-Purchase can only be configured from iTunesConnect •
  • 12.
  • 14. In-App Purchases Auto-Renewable Free Subscription
  • 15.
  • 16. Add Duration and Pricing Duration Sale or not Price Tier
  • 22.
  • 24. ATOM Feed • Apple’s server checks your new issues time to time to update iTunesConnect.
  • 25. Xcode
  • 27. Register Remote Notification - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options { ! // ... ! UIRemoteNotificationType type = UIRemoteNotificationTypeBadge | ! ! ! ! UIRemoteNotificationTypeSound | ! ! ! ! UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeNewsstandContentAvailability; ! [[UIApplication sharedApplication] registerForRemoteNotificationTypes:type]; }
  • 28. Newsstand Notification • Receive remote notification only once a day • You cannot push two contents a day • You can push regular push notifications multiple time • For debuging: [[NSUserDefaults standardUserDefaults] setValue:@YES forKey:@"NKDontThrottleNewsstandContentNotifications"];
  • 29. Send Token To Your Server with APS Environment - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token { #if DEBUG ! NSString *aps_environment = @"development"; Why? #else ! NSString *aps_environment = @"production"; #endif ! // send token to your server with other properties aps_environment }
  • 30. Different Token: Development/Production Debug Release APNS production Sandbox development app_id token environment com.electricwoo 0x123...af30 development Your ds.yourmagazine com.electricwoo 0x5c6...78c1 production Server APNS ds.yourmagazine Production
  • 31. Downloading New Issue Your Server APNS ① Push Notification ② Query Issues { Issue name, Published date, Download URL "aps":{ ! "content-available":1, }, ③ Download new Issue ... } Payload ④ Unzip* and move ⑤ Replace Newsstand Icon * optional
  • 32. Downloading New Issue - (void)downloadContentName:(NSString *)name URL:(NSURL *)URL date:(NSDate *)date { NKLibrary *lib = [NKLibrary sharedLibrary]; NKIssue *issue = [lib issueWithName:name]; if (!issue) { issue = [lib addIssueWithName:name date:date]; NKAssetDownload *download = [issue addAssetWithRequest: [NSURLRequest requestWithURL:URL]]; [download downloadWithDelegate:self]; } } - (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL { ! NSIssue *issue = connection.newsstandAssetDownload.issue; NSString *contentPath = issue.contentURL.path; // unzip destinationURL to contentPath }
  • 33. Restore Downloads at Launch Time ! Don’t forget NKLibrary *library = [NKLibrary sharedLibrary]; ! for (NKAssetDownload *download in library.downloadingAssets) { ! ! [download downloadWithDelegate:self]; ! }
  • 34. Making a list of Issues NKLibrary *lib = [NKLibrary sharedLibrary]; NSArray *issues = [lib issues]; Build a Great Bookshelf
  • 36. Auto-renewable Subscription • Newsstand App requires at least one Auto-renewable subscription or free subscription • Auto-renewable durations are: 7d, 1m, 2m, 3m, 6m, 1y • StoreKit won’t let app know duration from product identifier • Need to query to your server or hard-coded
  • 37. Restore Problem • What if Someone purchased auto-renewable subscriptions in-and-out few times • Purchased records can be retrieved by restore operation • But it can be cancelled, and StoreKit wouldn’t tell me... • Needs to ask to Apple’s server to verify those purchases Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
  • 38. Verifying Receipt - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue ! for (SKPaymentTransaction *transaction in queue.transactions) { ! ! NSString *identifier = transaction.payment.productIdentifier; ! ! switch (transaction.transactionState) { ! ! case SKPaymentTransactionStatePurchasing: // ... ! ! case SKPaymentTransactionStateFailed: // ... ! ! case SKPaymentTransactionStatePurchased: ! ! case SKPaymentTransactionStateRestored: ! ! ! [self verifyTransactionReceipt:transaction]; ! ! ! break; ! ! } ! } } - (void)verifyTransactionReceipt:(SKPaymentTransaction *)transaction { ... do your stuff ... [queue finishTransaction:transaction]; }
  • 39. DEBUG Verifying Receipts App Store Production { "receipt-data" : "(receipt bytes here)", "sandbox" : 1 } { "status" : 0, "receipt" : , "latest_receipt" : ... { 0 "latest_receipt_info" : ... "receipt-data" : "(receipt bytes here)", } "password" : "(shared secret bytes here)" OK } Sandbox { "status" : 0, App Store Your Server "receipt" : { (receipt here) }, "latest_receipt" : "(base-64 encoded receipt here "latest_receipt_info" : { (latest receipt info here }
  • 40. PRODUCTION Verifying Receipts App Store Production { { "receipt-data" : "(receipt bytes here)", "receipt-data" : "(receipt bytes here)", "password" : "(shared secret bytes he } } { "status" : 21006, { "receipt" : { (receipt here) }, "status" : 21006, "latest_receipt" : "(base-64 encoded re "receipt" : , "latest_receipt_info" : { (latest receip "latest_receipt" : ... } 21006 "latest_receipt_info" : ... } expired Sandbox App Store Your Server
  • 41. Auto renewable subscription recurring duration Production Sandbox 1 week 3 minutes 1 month 5 minutes 2 months 10 minutes 3 months 15 minutes 6 months 30 minutes 1 year 1 hour Automatically expires in 6th time recurring
  • 42. "receipt" :{ Not Expired "receipt":{ Expired "unique_identifier":"44f9ec48b952a....34e12c61c9c4f", "unique_identifier":"44f9ec48b952a....34e12c61c9c4f", "original_transaction_id":"1000000055744550", "original_transaction_id":"1000000055744550", "expires_date":"1348131173000", "expires_date":"1347344399000", "transaction_id":"1000000056135747", "transaction_id":"1000000055932398", "quantity":"1", "quantity":"1", "product_id":"yourmagazine.1mo", "product_id":"yourmagazine.1mo", "original_purchase_date_ms":"1347343199000", "original_purchase_date_ms":"1347343199000", "bid":"com.electricwoods.newsstand", "bid":"com.electricwoods.newsstand", "bvrs":"1.0", "bvrs":"1.0", "expires_date_formatted":"2012-09-20 08:52:53 Etc/GMT", "expires_date_formatted":"2012-09-11 06:19:59 Etc/GMT", "purchase_date":"2012-09-20 08:47:53 Etc/GMT", "purchase_date":"2012-09-11 06:14:59 Etc/GMT", "purchase_date_ms":"1348130873000", "purchase_date_ms":"1347344099000", "original_purchase_date":"2012-09-11 05:59:59 Etc/GMT", "original_purchase_date":"2012-09-11 05:59:59 Etc/GMT", "item_id":"558725164", "item_id":"558725164" }; }, “status”: 0 "status":21006
  • 44. These are what you get Newsstand Push Notification In App Purchase UIKit
  • 45. This is what you gonna build
  • 46. kyoshikawa@electricwoods.com Thank you Electricwoods LLC