0

In my iPhone application I want to trigger a download every monday of a week, every 10th working day of a month, every 3rd day of a month etc. I did some R & D and found that NSDate, NSDateComponents & NSCalendar classes needs to be used for this scenario. Can somebody help in the same as I am new to date & time usage.

Also by the time when trigger comes if app is not in running state or mobile is switched off.. How to handle these scenarios.

Srivathsa
  • 606
  • 10
  • 34

3 Answers3

1

Only legal way to do this is to schedule NSLocalNotification to desired date. When notification is fired up and user taps it, app would be started, and there you should start with download.

Ivan Alek
  • 1,899
  • 3
  • 19
  • 38
1

If you device is switched off / out of order / app is not running, you can not do any thing.

Apple would not allow you to launch your automatically, so the question of downloading and saving is bit far.

What you can do is, whenever your app is launched you can read from plist or userdefaults about the time ( 3rd day of month ) and compare to the last saved date, if it is one month away then it is the time to download and show a popup to do so.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • Hi All, Thanks for overwhelming possible solutions. I see what AKV is proposed may work for my scenario. I see NSLocalNotification feature also can help me along with this approach. I yet to develop any POC for a trail purpose. I need to accept both Ivan Alek & AKV answers as both may be required to solve the puzzle. No such option so I am accepting AKV solution. I will post once i am done with some test app for doing this. It helped me a lot. Thank you very much everyone. – Srivathsa Jan 28 '13 at 08:46
  • Hi I am trying to read data from a pList. everything going smooth but can you tell me how to save the changes into the same pList. I googled for it and came to know we can't write to a pList which is in Bundle. Any help or sample code to save plist is highly appreciated. – Srivathsa Jan 30 '13 at 13:04
1

The documentation for Local Notifications: Local Notifications

You can read this: iOS timed background processing

Can go through this tutorial as well. I have reading up as well. Something new for me as well. Best is NSLocalNotifications. Have a look at this: Reminder App

Community
  • 1
  • 1
lakshmen
  • 28,346
  • 66
  • 178
  • 276