title: iOS In app purchase : request latest cancellation date and number of cancellations
body: <p>I am working with iOS In-App Purchase.</p>
  
  <p>I would like to request the latest cancellation date and the total number of cancellations preferably with 100% correct result.</p>
  
  <p>I am using Apple's verifyreceipt call </p>
  
  <pre><code>(
  https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1 
  -&gt; 
  https://sandbox.itunes.apple.com/verifyReceipt 
  / 
  https://buy.itunes.apple.com/verifyReceipt 
  JSON response field descriptions : https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW25
  ) .
  </code></pre>
  
  <p>The JSON response has this format : </p>
  
  <pre><code>(lldb) po jsonResponse
  {
      environment = Sandbox;
      "latest_receipt" = "&lt;some binary text&gt;";
      "latest_receipt_info" =     (
                  {
              "expires_date" = "2017-11-17 15:41:31 Etc/GMT";
              "expires_date_ms" = 1510933291000;
              "expires_date_pst" = "2017-11-17 07:41:31 America/Los_Angeles";
              "is_trial_period" = true;
              "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
              "original_purchase_date_ms" = 1510929694000;
              "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "purchase_date" = "2017-11-17 14:41:31 Etc/GMT";
              "purchase_date_ms" = 1510929691000;
              "purchase_date_pst" = "2017-11-17 06:41:31 America/Los_Angeles";
              quantity = 1;
              "transaction_id" = 1000000353161868;
              "web_order_line_item_id" = 1000000036932780;
          },
                  {
              "expires_date" = "2017-11-17 15:46:31 Etc/GMT";
              "expires_date_ms" = 1510933591000;
              "expires_date_pst" = "2017-11-17 07:46:31 America/Los_Angeles";
              "is_trial_period" = false;
              "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
              "original_purchase_date_ms" = 1510929694000;
              "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "purchase_date" = "2017-11-17 15:41:31 Etc/GMT";
              "purchase_date_ms" = 1510933291000;
              "purchase_date_pst" = "2017-11-17 07:41:31 America/Los_Angeles";
              quantity = 1;
              "transaction_id" = 1000000353176570;
              "web_order_line_item_id" = 1000000036932781;
          },
                  {
              "expires_date" = "2017-11-17 15:51:31 Etc/GMT";
              "expires_date_ms" = 1510933891000;
              "expires_date_pst" = "2017-11-17 07:51:31 America/Los_Angeles";
              "is_trial_period" = false;
              "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
              "original_purchase_date_ms" = 1510929694000;
              "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "purchase_date" = "2017-11-17 15:46:31 Etc/GMT";
              "purchase_date_ms" = 1510933591000;
              "purchase_date_pst" = "2017-11-17 07:46:31 America/Los_Angeles";
              quantity = 1;
              "transaction_id" = 1000000353177515;
              "web_order_line_item_id" = 1000000036933429;
          },
                  {
              "expires_date" = "2017-11-17 15:56:31 Etc/GMT";
              "expires_date_ms" = 1510934191000;
              "expires_date_pst" = "2017-11-17 07:56:31 America/Los_Angeles";
              "is_trial_period" = false;
              "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
              "original_purchase_date_ms" = 1510929694000;
              "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "purchase_date" = "2017-11-17 15:51:31 Etc/GMT";
              "purchase_date_ms" = 1510933891000;
              "purchase_date_pst" = "2017-11-17 07:51:31 America/Los_Angeles";
              quantity = 1;
              "transaction_id" = 1000000353178539;
              "web_order_line_item_id" = 1000000036933488;
          },
                  {
              "expires_date" = "2017-11-17 16:01:31 Etc/GMT";
              "expires_date_ms" = 1510934491000;
              "expires_date_pst" = "2017-11-17 08:01:31 America/Los_Angeles";
              "is_trial_period" = false;
              "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
              "original_purchase_date_ms" = 1510929694000;
              "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "purchase_date" = "2017-11-17 15:56:31 Etc/GMT";
              "purchase_date_ms" = 1510934191000;
              "purchase_date_pst" = "2017-11-17 07:56:31 America/Los_Angeles";
              quantity = 1;
              "transaction_id" = 1000000353179673;
              "web_order_line_item_id" = 1000000036933554;
          },
                  {
              "expires_date" = "2017-11-17 16:06:31 Etc/GMT";
              "expires_date_ms" = 1510934791000;
              "expires_date_pst" = "2017-11-17 08:06:31 America/Los_Angeles";
              "is_trial_period" = false;
              "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
              "original_purchase_date_ms" = 1510929694000;
              "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "purchase_date" = "2017-11-17 16:01:31 Etc/GMT";
              "purchase_date_ms" = 1510934491000;
              "purchase_date_pst" = "2017-11-17 08:01:31 America/Los_Angeles";
              quantity = 1;
              "transaction_id" = 1000000353180672;
              "web_order_line_item_id" = 1000000036933616;
          },
                  {
              "expires_date" = "2017-11-18 16:03:15 Etc/GMT";
              "expires_date_ms" = 1511020995000;
              "expires_date_pst" = "2017-11-18 08:03:15 America/Los_Angeles";
              "is_trial_period" = false;
              "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
              "original_purchase_date_ms" = 1510929694000;
              "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "purchase_date" = "2017-11-18 15:58:15 Etc/GMT";
              "purchase_date_ms" = 1511020695000;
              "purchase_date_pst" = "2017-11-18 07:58:15 America/Los_Angeles";
              quantity = 1;
              "transaction_id" = 1000000353294875;
              "web_order_line_item_id" = 1000000036933659;
          }
      );
      "pending_renewal_info" =     (
                  {
              "auto_renew_product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
              "auto_renew_status" = 1;
              "original_transaction_id" = 1000000353161868;
              "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
          }
      );
      receipt =     {
          "adam_id" = 0;
          "app_item_id" = 0;
          "application_version" = 759;
          "bundle_id" = "com.myapp";
          "download_id" = 0;
          "in_app" =         (
                          {
                  "expires_date" = "2017-11-17 15:46:31 Etc/GMT";
                  "expires_date_ms" = 1510933591000;
                  "expires_date_pst" = "2017-11-17 07:46:31 America/Los_Angeles";
                  "is_trial_period" = false;
                  "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
                  "original_purchase_date_ms" = 1510929694000;
                  "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
                  "original_transaction_id" = 1000000353161868;
                  "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
                  "purchase_date" = "2017-11-17 15:41:31 Etc/GMT";
                  "purchase_date_ms" = 1510933291000;
                  "purchase_date_pst" = "2017-11-17 07:41:31 America/Los_Angeles";
                  quantity = 1;
                  "transaction_id" = 1000000353176570;
                  "web_order_line_item_id" = 1000000036932781;
              },
                          {
                  "expires_date" = "2017-11-17 15:51:31 Etc/GMT";
                  "expires_date_ms" = 1510933891000;
                  "expires_date_pst" = "2017-11-17 07:51:31 America/Los_Angeles";
                  "is_trial_period" = false;
                  "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
                  "original_purchase_date_ms" = 1510929694000;
                  "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
                  "original_transaction_id" = 1000000353161868;
                  "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
                  "purchase_date" = "2017-11-17 15:46:31 Etc/GMT";
                  "purchase_date_ms" = 1510933591000;
                  "purchase_date_pst" = "2017-11-17 07:46:31 America/Los_Angeles";
                  quantity = 1;
                  "transaction_id" = 1000000353177515;
                  "web_order_line_item_id" = 1000000036933429;
              },
                          {
                  "expires_date" = "2017-11-17 15:56:31 Etc/GMT";
                  "expires_date_ms" = 1510934191000;
                  "expires_date_pst" = "2017-11-17 07:56:31 America/Los_Angeles";
                  "is_trial_period" = false;
                  "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
                  "original_purchase_date_ms" = 1510929694000;
                  "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
                  "original_transaction_id" = 1000000353161868;
                  "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
                  "purchase_date" = "2017-11-17 15:51:31 Etc/GMT";
                  "purchase_date_ms" = 1510933891000;
                  "purchase_date_pst" = "2017-11-17 07:51:31 America/Los_Angeles";
                  quantity = 1;
                  "transaction_id" = 1000000353178539;
                  "web_order_line_item_id" = 1000000036933488;
              },
                          {
                  "expires_date" = "2017-11-17 16:01:31 Etc/GMT";
                  "expires_date_ms" = 1510934491000;
                  "expires_date_pst" = "2017-11-17 08:01:31 America/Los_Angeles";
                  "is_trial_period" = false;
                  "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
                  "original_purchase_date_ms" = 1510929694000;
                  "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
                  "original_transaction_id" = 1000000353161868;
                  "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
                  "purchase_date" = "2017-11-17 15:56:31 Etc/GMT";
                  "purchase_date_ms" = 1510934191000;
                  "purchase_date_pst" = "2017-11-17 07:56:31 America/Los_Angeles";
                  quantity = 1;
                  "transaction_id" = 1000000353179673;
                  "web_order_line_item_id" = 1000000036933554;
              },
                          {
                  "expires_date" = "2017-11-17 16:06:31 Etc/GMT";
                  "expires_date_ms" = 1510934791000;
                  "expires_date_pst" = "2017-11-17 08:06:31 America/Los_Angeles";
                  "is_trial_period" = false;
                  "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
                  "original_purchase_date_ms" = 1510929694000;
                  "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
                  "original_transaction_id" = 1000000353161868;
                  "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
                  "purchase_date" = "2017-11-17 16:01:31 Etc/GMT";
                  "purchase_date_ms" = 1510934491000;
                  "purchase_date_pst" = "2017-11-17 08:01:31 America/Los_Angeles";
                  quantity = 1;
                  "transaction_id" = 1000000353180672;
                  "web_order_line_item_id" = 1000000036933616;
              },
                          {
                  "expires_date" = "2017-11-18 16:03:15 Etc/GMT";
                  "expires_date_ms" = 1511020995000;
                  "expires_date_pst" = "2017-11-18 08:03:15 America/Los_Angeles";
                  "is_trial_period" = false;
                  "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
                  "original_purchase_date_ms" = 1510929694000;
                  "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
                  "original_transaction_id" = 1000000353161868;
                  "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
                  "purchase_date" = "2017-11-18 15:58:15 Etc/GMT";
                  "purchase_date_ms" = 1511020695000;
                  "purchase_date_pst" = "2017-11-18 07:58:15 America/Los_Angeles";
                  quantity = 1;
                  "transaction_id" = 1000000353294875;
                  "web_order_line_item_id" = 1000000036933659;
              },
                          {
                  "expires_date" = "2017-11-17 15:41:31 Etc/GMT";
                  "expires_date_ms" = 1510933291000;
                  "expires_date_pst" = "2017-11-17 07:41:31 America/Los_Angeles";
                  "is_trial_period" = true;
                  "original_purchase_date" = "2017-11-17 14:41:34 Etc/GMT";
                  "original_purchase_date_ms" = 1510929694000;
                  "original_purchase_date_pst" = "2017-11-17 06:41:34 America/Los_Angeles";
                  "original_transaction_id" = 1000000353161868;
                  "product_id" = "com.myapp.iap.pro.renewing.monthly.trial";
                  "purchase_date" = "2017-11-17 14:41:31 Etc/GMT";
                  "purchase_date_ms" = 1510929691000;
                  "purchase_date_pst" = "2017-11-17 06:41:31 America/Los_Angeles";
                  quantity = 1;
                  "transaction_id" = 1000000353161868;
                  "web_order_line_item_id" = 1000000036932780;
              }
          );
          "original_application_version" = "1.0";
          "original_purchase_date" = "2013-08-01 07:00:00 Etc/GMT";
          "original_purchase_date_ms" = 1375340400000;
          "original_purchase_date_pst" = "2013-08-01 00:00:00 America/Los_Angeles";
          "receipt_creation_date" = "2017-11-18 15:58:18 Etc/GMT";
          "receipt_creation_date_ms" = 1511020698000;
          "receipt_creation_date_pst" = "2017-11-18 07:58:18 America/Los_Angeles";
          "receipt_type" = ProductionSandbox;
          "request_date" = "2017-11-18 15:58:23 Etc/GMT";
          "request_date_ms" = 1511020703927;
          "request_date_pst" = "2017-11-18 07:58:23 America/Los_Angeles";
          "version_external_identifier" = 0;
      };
      status = 0;
  }
  </code></pre>
  
  <p>I don't see any way to extract the "number of cancellations" info from this response. Is there any way to do it? Possibly using a different request for example?</p>
  
  <p>As I see I can get the "latest cancellation date" by checking the value of "pending_renewal_info" : "auto_renew_status" == 0 and iterating over the array of receipts and getting the latest expiration date (maybe with adding a safety check that it is less than the current date).
  But : as I see this solution does not give 100% correct result, because : 
  in case if a user has a cancelled subscription and renews it outside the app without starting the app, my app won't be able to identify that cancellation.
  Is there any way to request this information?</p>