i want to know if it is possible to launch a background process in iOS. In my background process every 30 minutes there should a function get called, in order to check in my database if there are new messages, etc in order to send a notification. I don't want to implement push notifications. I don't know where to implement this feature, and if there are override functions e.g. in the AppDelegate.
Thanks for your help, hannes
For background
In your viewDidLoad() method
Add this method in your ViewController
For Forground
What you want is called "Background Fetch" and is available starting from iOS 7:
https://www.objc.io/issues/5-ios7/multitasking/
I would recommend that you take a look at Apple's documentation on Background Execution. It states all the possible ways to run code in the background. Each method comes with it's limitations, advantages and disadvantages and also Apple mentions:
If your iOS application does not communicate over Bluetooth (BTLE or with MFi certified devices) with some device (you could configure that Bluetooth device to send some event to the iOS device every 30 minutes and execute your code when that happens), then the most reliable way to run some code every 30 minutes is by using silent push notifications.
Silent push notifications can be configured so that they're not shown to the user, but allows your code to run. The limitations with push notifications are that the user needs an active internet connection to receive them and the user needs to give your app permission to use push notifications (you can request this at app's first run).
I noticed that your questions mentions I don't want to use push notifications, but unfortunately you don't really have a choice here.
Yes it is possible to launch a background process in iOS. It is also possible to launch this process every 30 minutes. You need to setup two things! You need to send every 30 minutes a silent Push with your server.(e.g. with a Cloud Code job in Parse(Warning! Since Parse will be shutdowned in January 2017, it is not clever working on this platform)
This silent push initiate an NSURLBackgroundSession which pulls the desired data from your server and process it.
Your need to activate this in the project settings
1.) Add this in AppDelgate for receiving pushes
When you get a push from a server or something else, following delegate method will be called: (so add this too in your appDelegate)
The method which is called now needs to pull the data from your database. In this case you use a NSURLSession to download whatever you need.
2.) Go to the ViewController where the data get processed and add: the NSURLSessionDownloadDelegate delegate with the required delegate methods
When the downloadTask is successfully completed
will be called and you can process the data
You can alternatively do this with a NSURLSessionDataTask