How can my app know if it is opened from widget?

315 views Asked by At

I have set up a widget and made it able to open the main app successfully. But I can't seem to make the main app "aware" of the way it's opened. I want the app to be able to distinguish the way it's opened, be it from (1) the main screen or (2) the widget. In the case of (2), the app should then proceed to read from UserDefaults(suiteName:).

Yes, there are many similar questions here but I have not yet find a solution.

These are functions in the AppDelegate.swift did not even get called (and I have no idea why):

1.

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool

2.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

3.

func applicationWillEnterForeground(_ application: UIApplication)

4.

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool

This is my first try on Today Extension and please send help if you've found the problem or want to know more of my code. Thank you in advance!

0

There are 0 answers