1

I'm trying to breakpoint didFinishLaunchingWithOptions in my app delegate to capture the app being launched (in the background) when a newsstand issue download completes after the app was terminated. I believe it could happen for example if a user manually requests a download and then terminates the app.

On the info tab of the run scheme in the Xcode scheme editor there is an option to wait for the app to launch. The comment below it says that it is to be used when you want to launch your app manually. Although that isn't what I want, I have tried it anyway and not surprisingly it doesn't seem to do what I want. Does anyone else have a way of doing this?

Martin Lockett
  • 2,275
  • 27
  • 31
  • Isn't [NKIssueDownloadCompletedNotification](http://developer.apple.com/library/ios/documentation/StoreKit/Reference/NKIssue_Class/NKIssue/NKIssue.html#//apple_ref/c/data/NKIssueDownloadCompletedNotification) is what you need? I'm not sure if you can use it when app downloads it in background? How do you think? – DanSkeel Sep 25 '12 at 14:11
  • That would work if the app was running (or maybe in the background) when the download completes. I have identified two scenarios where the app might have been terminated before the download is completed (see comment below). I am now assuming that a terminated app will not be launched on completion of the download. – Martin Lockett Sep 29 '12 at 12:57

1 Answers1

3

Wait for your.app to launch can be used to delay the launch of the debugger. Its very useful in testing newsstand updates arriving after simulating a push notification.

You can put a breakpoint on application:didFinishLaunchingWithOptions: and then trigger your push notification which will simulate a newsstand issue arriving

Remember, if you a testing - you want to ensure you don't throttle newsstand updates. In production you can only get 1 per day, so add this:

#ifdef DEBUG
    // For debugging - allow multiple pushes per day
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NKDontThrottleNewsstandContentNotifications"];
    [[NSUserDefaults standardUserDefaults] synchronize];
#endif

Is this what you were looking for? If not please elaborate.

bandejapaisa
  • 26,576
  • 13
  • 94
  • 112
  • No. I want to capture the app launching when a download has completed. However, I can't see why the wait for launch would work for notifications (UIApplicationLaunchOptionsRemoteNotificationKey) but not for UIApplicationLaunchOptionsNewsstandDownloadsKey. I've given you +1 for the tip about throttling though. Thanks! – Martin Lockett Jan 18 '12 at 09:44
  • What are you expecting? The app isn't going to launch when the download has completed. With newsstand, your app receives a newsstand push message, if its in the background it wakes up (but remains in the background) - downloads the issue, and then goes back to sleep. It doesn't become the foreground app. Is UIApplicationLaunchOptionsNewsstandDownloadsKey used for download's currently in progress? – bandejapaisa Jan 18 '12 at 11:59
  • 1
    There are two scenarios I can think of: 1 The user initiates a download of a previously purchased, downloaded and then archived product; then terminates the app. 2: A push notification initiates a background download and during this download, the user uses the app and then terminates it. As there is a UIApplicationLaunchOptionsNewsstandDownloadsKey which is used to launch the app I assumed it indicated that the specified assets have been downloaded and need attention. If not, what is it for? As you have now explained that this will not happen I'll take that as a solution to my problem. – Martin Lockett Jan 18 '12 at 13:33
  • I am creating a newsstand application I am new in it. so how can I get a newsstand issue notification. whether I must use NKAssetDownload and move the content to contentURL path of NKIssue?. Why I am asking is I have a another working magazine solution of ipad how can i reuse it. – Naveen Shan Feb 28 '13 at 11:59