Question

Hi i am developing an app that will fetch one qoute from my server everyday and will do a local notification in that app and more when you get inside the app. I started by implementing Push Notification but then i figured that Local Notifications is what i need.

Official Documentation

For example, applications that depend on servers for messages or data can poll their servers for incoming items while running in the background; if a message is ready to view or an update is ready to download, they can then present a local notification immediately to inform their users.

The work flow of my app is that i need the app to make a post request to get today's quote and fire a local notification for that (that's the hard part) then when user opens the app i think things are easy. Th issue here is that that request has to be made while my app is not running. I'm looking for some help on how to acheive that.. Thanks in advance

Was it helpful?

Solution

Apple introduced in iOS 7 something called Background fetch.

The new Background Fetch capability allows your application to ask to fetch data on a regular basis, so when the user launches or re-opens your application, it can start up with the most current data possible.

You can learn how to implement it here

Another option to consider iOS Silent Push notifications. This will let you update the user database without interacting with him. I'd go with Background fetch, though.

OTHER TIPS

I don't think you can run your app in background unless your app meets one of the background modes specified by apple . If you run your app in background without enabling one of the background modes it may result in app rejection by apple .

Now for your requirement you can simply save the qoute for a particular date from server within local DB once a day whenever user runs the app . By setting local Notification repeat itself at morning everyday you can display qoute of that particular date .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top