Summary: There are situations when applications do not want Universal Links to be handled by the System, but prefer the link to be opened in the WKWebView itself. For example, when using a WKWebView in a "private browsing" mode as specified by [WKWebsiteDataStore nonPersistentDataStore], the hosting WKWebView application should be able to prevent opening the Universal Link from opening the native application. Steps to Reproduce: 1. Install and log into the LinkedIn app 2. Create WKWebView with [WKWebsiteDataStore nonPersistentDataStore] 3. Navigate to search engine and search for a LinkedIn user's profile 4. Click on the user's profile Expected Results: Application should be able to disable the system opening the LinkedIn app. Actual Results: LinkedIn app is launched, user unexpectedly looses private context. Version: iOS 9.3.2 (13F69) radar://26683207
Created attachment 362139 [details] Patch
achristensen@, please take a look. This was the suggested method to support blocking universal links from opening native applications when a user is within a "private" browsing mode. Thank you!
This is absolutely the approach I suggested, and I think it looks good. However, adding private functions won't help you. We will have to do the internal process to get new public API approved, which will not be documented in Bugzilla. This patch gives us a starting point, though. Thanks!
Yes,, they would need to be made public. No problem, please let me know if there is anything I can do to help. Thank you for taking a look! (Should I follow up on submitting this change or will it remain in this state and just be replicated later on if the internal processes approves a public version?)
I think it would be a more flexible design to control this through a delegate method. Perhaps decidePolicyForNavigationAction can make the choice? That way, apps could decide on a case by case basis whether to open a webpage inline or open an associated app. Poking around, it seems there is already a private _WKNavigationActionPolicyAllowWithoutTryingAppLink which would continue the navigation without trying universal links. I suspect making that public is the right approach.
Thanks! Making _WKNavigationActionPolicyAllowWithoutTryingAppLink public works for Chrome.