Reputation: 1095
I have web-view
based app and other native apps in company. We were using universal links
to redirect user to other apps when needed (other apps still support universal links
- I can run them by pressing links from Apple Notes app
).
We recently made a transition to WKWebView
(from UIWebView
), which provides a way better experience. But after the update Universal Links
stopped working and we cannot start other apps when user press link inside our app.
According to the docs:
"Universal links let iOS 9 users open your app when they tap links to your website within WKWebView and UIWebView views and Safari pages, in addition to links that result in a call to openURL:, such as those that occur in Mail, Messages, and other apps."
It seems that WKWebView
is not handling the Universal Links
. My questions is, am I missing some special configuration for WKWebView
or this is WebKit
bug? I'm creating web view as provided:
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.allowsInlineMediaPlayback = YES;
config.processPool = // Here I'm using shared process pool
self.webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
self.webView.translatesAutoresizingMaskIntoConstraints = NO;
self.webView.clipsToBounds = YES;
self.webView.allowsBackForwardNavigationGestures = YES;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
self.webView.allowsLinkPreview = YES;
}
[self addSubview:_webView];
To show the problem I have created simple repository with simple app (https://github.com/apan06/UniversalLinks - with very simple initialisation). There are two web views - WKWebView
and UIWebView
with both with simple html that there is only link to Twitter
. WKWebView
simply loads the Twitter
page. On the other hand UIWebView
open Twitter
app. Just remembet:
- test it on device with Twitter
app installed, if you don't have Twitter app
or don't like Twitter you can change link
- I was testing it on iPhone 6
with iOS 9.2.1
Thanks!
Upvotes: 4
Views: 2984
Reputation: 76
I believe there is a bug in WKWebView that makes it ignore universal links if the navigation delegate is not set. Try setting the WKWebView’s navigation delegate. You don’t have to implement any of the delegate methods.
Upvotes: 0