Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my "didFinishLaunchingWithOptions" wait until call api finish

Tags:

ios

swift

api

How can my application wait until my call api is finished ?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    GMSServices.provideAPIKey("AIzadGlsfR35k4BeHCXmRq3GDSQ-l_5gcD8")
    FlicAuth.sharedInstance

    //Call Api here

    application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil))
    application.registerForRemoteNotifications()

    if(launchOptions?[UIApplicationLaunchOptionsLocationKey] != nil){
        LocationService.sharedInstance.startMonitoringLocation()
    }

    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

Thank's in advance

like image 978
YouSS Avatar asked Feb 08 '23 06:02

YouSS


1 Answers

It's very wrong, but for your problem i've a better solution.

Create a viewController exactly same as your splash screen and set as initial viewController.. perform your operation in that viewController's class and after Api success you can navigate to your actual screen or change the root programmatically

like image 116
Utkarsh Singh Avatar answered Feb 09 '23 19:02

Utkarsh Singh