1

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!

Lambdalex
  • 481
  • 1
  • 5
  • 10
  • I do have a similar problem. You should probably look for your Scene Delegate and implement the two methods scene(_:willConnectTo:options:) and scene(_:openURLContexts:). Documented here https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content/defining_a_custom_url_scheme_for_your_app But there is still missing, that the source Application is not nil, which seems a privacy improvement in iOS 13. – Martin Apr 24 '20 at 12:04

0 Answers0