9

I have enabled Universal Links in my app. The corresponding delegate call to handle those links is

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    if canHandle(userAcitivity) {
        // Handle the universal link.
    }
    else {
        // ⛔️ Don't handle the universal link.
        return false
    }
}

No I wonder what exactly happens when I return false from this method. In the beginning I thought that Safari would simply open the link instead as it would without universal links enabled. However, I figured that my app is still opened and the documentation states:

If you do not implement this method or if your implementation returns false, iOS tries to create a document for your app to open using a URL.

What exactly does this mean?

What kind of document is created and how is my app notified about that?

Mischa
  • 15,816
  • 8
  • 59
  • 117

1 Answers1

1

Actually, for continueUserActivity the description of the return value is:

Returns true to indicate that your app handled the activity or false to let iOS know that your app did not handle the activity.

If you return YES from this function the OS will understand that no further processing of the NSUserActivity will be required - your app has done everything that needs to be done. If you return NO from this function, the OS will understand that an activity requiring OS processing may have occurred and may need to be handled.

You can get more background on all this in Apple's Handoff docs, here: https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html#//apple_ref/doc/uid/TP40014338

dwestgate
  • 1,044
  • 6
  • 12