LaunchOptions is always nil with SceneDelegate

Viewed 227

I have investigated siginificant location. I would like to get location information when not running app. https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/using_the_significant-change_location_service

The following code is an trigger for getting location information.

func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        if launchOptions?[.location] != nil {
            locationManager.startMonitoringSignificantLocationChanges()
        }
        return true
    }

But I encountered a strange behavior.
When an app launch by significant location event.

AppDelegate only: launchOptions?[.location] isn’t nil
AppDelegate + SceneDelegate: launchOptions?[.location] is always nil

I couldn’t get similar value from SceneDelegate method.

SceneDelegate screenshot

If I want to use launchOptions related to location, is it better to use AppDelegate only?

0 Answers
Related