How to detect if App Launch was user-initiated?

Viewed 61

As we all know, application(_:didFinishLaunchingWithOptions:) callback is called after app is almost ready to run, but there are cases, that push notifications, voip-push notifications, etc. do call this method as well, when app terminated to perform some tasks.

I need a solid answer, is there a way to tell when app launch was user-initiated, or something else did order app launch from background?

Is it safe to assume that the method parameter launchOptions: [UIApplication.LaunchOptionsKey : Any]? will always be nil on user-initiated launch?

1 Answers

Is it safe to assume that the method parameter launchOptions: [UIApplication.LaunchOptionsKey : Any]? will always be nil on user-initiated launch?

No, absolutely not. For example if the user launches your app by way of a Quick Action, that is user-initiated but the Quick Action will be in the launch options.

However, if the launchOptions is empty, you can pretty much rely on the fact that the user tapped the app's icon in the springboard.

Related