Is it Possible to run a task before app starts?

Hi

I am doing a project in which the design/structure of the app will change based on web APIs.

Is it possible to call web APIs just before the app Starts?

Accepted Reply

Just define a flag Bool property for the whole app as I told.

Then, in viewWillappear, use it to show / hide UI elements, such as:

myLabel.isHidden = flag // or !flag


To call API when resuming App, do it in AppDelegate, inside


    func applicationWillEnterForeground(_ application: UIApplication) { }

Replies

This is not clear.


If you want to test web Api before app starts, you cannot do it in the app !

How different are the 2 designs ? Could you illustrate with some examples


So, you need to have a first app that tests and then launch the right app from there.


But there is another way (if I understand what you want):

you could also have both "designs" in the same app, Of course, you would have 2 variants of some struct, may be classes, may be some vars

Then, for readability, you should adopt a naming that's explicit, like myVarCase1 and myVarCase2

have a flag to test.

this flag should be set in appDidFinishLaunching


Then, everywhere, use the flag to know which version of objects to use.

Hi Claude31,

Thank you very much for your suggestion.

To clarify, it is not 2 designs.It is, based upon the APIs response i will change the UI.(For example, adding or removing a label )

i understood that it is not possible to call Apis before app launch.

When i press home button,app will go to background.

Now, when ever i start the app again,is it possible to call few Apis and according to that response ,is it possbile to change the UI?

Just define a flag Bool property for the whole app as I told.

Then, in viewWillappear, use it to show / hide UI elements, such as:

myLabel.isHidden = flag // or !flag


To call API when resuming App, do it in AppDelegate, inside


    func applicationWillEnterForeground(_ application: UIApplication) { }

Hi Claude31,

Thank you very much for your support.