How to execute code without the app open?

I want to create a app that has to load data from my API on a regular basis. The data is changed every 15 minutes so I would like to use a similar interval to load my data to update my widget and the data in the app. But what is the proper way of implementing such behavior? I mean the app would need to update the data even when the app is closed in the app switcher to update the widget and so on.

Background fetch seems to be the wrong way to me, and I'm also not sure about BGTaskScheduler. As far as I understand this, both needs to be started from my app which may not be opened after a device reboot.

I'm sure there must be a way to implement the wanted behavior because mail apps need todo the very same on servers that do not support push.
How to execute code without the app open?
 
 
Q