0

I need to run a function which call an API to give the app some information for the whole 24 hours. I need to call the function every 6 AM. When I search, I only find how to do that for notification. Can I do that without resorting to use notification? Using notification to achieve this feels like using a complicated tools to achieve something that's actually unrelated, which could make the code looks convoluted. Thanks.

Community
  • 1
  • 1
Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124
  • 2
    Why do you need to do this? If the user isn't running your app for several days, why download data each day? – rmaddy Feb 17 '17 at 05:19
  • @rmaddy because this is an app for iPad tablets which will be put on toilets for user feedback after using it. The tablet will run this app the whole day 24/7, and will need to download new data for running marquee text and videos URL, potentially for advertising purposes. – Chen Li Yong Feb 17 '17 at 05:25
  • If the app will be the only app running and it is always running, then your task is simple. Set a timer to go off at 6am and you are done. – rmaddy Feb 17 '17 at 05:27
  • 1
    @rmaddy oh, okay. I thought timer can only run immediately at an interval time. But after reading your answer, I do some search and found out that timer can fire off begin at a specified time. https://www.hackingwithswift.com/example-code/system/how-to-run-code-at-a-specific-time – Chen Li Yong Feb 17 '17 at 05:49

0 Answers0