0

Why do ARKit engineers put ARFaceTrackingConfiguration.isSupported statement in AppDelegate.swift file but not in ViewController.swift file?

class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {

        if !ARFaceTrackingConfiguration.isSupported {               
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            window?.rootViewController = storyboard.instantiateViewController(withIdentifier: "unsupportedDeviceMessage")
        }
        return true
    }
}

I think a ViewController.swift file is the most suitable place for this conditional statement.

Am I right?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220

1 Answers1

0

After investigation I decided that application(_:willFinishLaunchingWithOptions:) instance method is better suited for instantiating a storyboard (and then presenting a ViewController) inside an if-statement checking ARFaceTrackingConfiguration.

Here's what Apple says about this method:

Use this instance method to initialise your app and prepare it to run. This method is called after your app has been launched and its main storyboard or nib file has been loaded, but before your app’s state has been restored. At the time this method is called, your app is in the inactive state.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220