title: In App Purchase Download is not happening
body: <p>I got a download from Apple server hosted content to work, but in further development of my IAP UI, I've come across a situation where I need to redownload the content.</p>
  
  <p>The content in this case is a zip file, which was created in Xcode as a bundle of images and a plist file containing associated data.</p>
  
  <p>The original download worked fine, and I was able to process the zip file as if it were a directory.</p>
  
  <p>In continuing to develop the app, I deleted the app from my test device. That meant the content was no longer on the device. The in app transaction was never completed, so I expected the download to process again.</p>
  
  <p>Originally, the zip file got downloaded and saved to the caches directory, and I was able to process it from there. Now, though, it seems like the IAP framework thinks the zip file is there but it really isn't. The <code>paymentQueue:updatedDownloads:</code> method is triggered with download state equal to <code>SKDownloadStateFinished</code> without any download activity happening. OK. That's not in my control. I need to just look at the URL of the download I was given, right? So, within <code>case SKDownloadStateFinished:</code> I have a call to <code>[self processURL:download.contentURL fromProduct:download.contentIdentifier];</code>, which processes the referenced download. Here is the start of that method:</p>
  
  <pre><code>-(void)processURL:(NSURL *)directoryURL fromProduct:(NSString *)productIdentifier
  {
     int itemsAdded = 0;
     NSFileManager *filemanager = [NSFileManager defaultManager];
     NSMutableSet *masterIndex = [NSMutableSet new];
     BOOL isDir;
     if ([filemanager fileExistsAtPath:[directoryURL path] isDirectory:&amp;isDir]) {
        NSLog(@"URL %@ exists. Is it a directory? %@",directoryURL,isDir?@"YES":@"NO");
     } else {
        NSLog(@"URL %@ does not exist.",directoryURL);
     }
  </code></pre>
  
  <p>What I am getting as output is:</p>
  
  <pre><code>URL file://localhost/private/var/mobile/Applications/40733984-E18D-4450-A98E-D8CCC56D2600/Library/Caches/8E29E63C-9C32-4D92-AC84-23BDA946DE5F.zip/ does not exist.
  </code></pre>
  
  <p>A call to <code>[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];</code> doesn't seem to help. It just thinks it's finished without redownloading the zip file.</p>
  
  <p>Any suggestions on what to do?</p>
  
  <p>EDIT: This is really getting frustrating. Since my original post, I've tried the following:
  * Rebooted my iPad
  * Restarted Xcode
  * Ran a clean on my iPad (I wasn't holding my breath - I was hoping to clear the caches directory, which I think is inaccessible to the cleaning utility)
  * Updated my in app purchase package with updated information in the plist file.
  * Updated the version of the in app purchase package.</p>
  
  <p>When it tries to download, it is still trying to download the same zip file name, and it still doesn't exist. I thought by changing the package, even with the same package name, the download would pull a different zip name. But maybe it's just a hash or the package name.</p>
  
  <p>I have an idea that the caches directory is corrupted somehow. My next step will be to create another package with a different package name. I'm guessing this will work fine, but that doesn't resolve my problem.</p>
  
  <p>I also have an idea of the circumstances that may have caused the problem. It seems like Xcode 5 is slower to respond to pressing the build and run button. The result was that I clicked it twice. Of course, that causes problems. In this case, I got some sort of deadly embrace, I think, that locked up my iPad. I had to manually power it down and restart it twice before it came back again properly.</p>
  
  <p>Edit:
  The new items are not downloading. Here's a checklist of items I've checked. Please edit this to include more items to check if you think of more.</p>
  
  <ul>
  <li>Make sure the test user has not been used in production. If so, a new test user will need to be created.</li>
  <li>Make sure the object registers as an SKPaymentTransactionObserver. This includes setting up the interface, and also making the call <code>[[SKPaymentQueue defaultQueue] addTransactionObserver:self]</code> at startup.</li>
  <li>Make sure user can make payments.</li>
  <li>Make sure <code>transaction.transactionState == SKPaymentTransactionStatePurchased</code> (or <code>SKPaymentTransactionStateRestored</code> if restoring a transaction)</li>
  <li>Make sure the transaction is not finished (<code>[[SKPaymentQueue defaultQueue] finishTransaction:transaction]</code>).</li>
  <li>Make sure the product ID matches to product ID set up in iTunes Connect (well, you wouldn't have been able to purchase it if this weren't true).</li>
  <li>Test on a physical device. These downloads cannot be tested on the simulator.</li>
  <li>(speculative) turn off notifications for App Store to prevent test user from being nullified.</li>
  </ul>