Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Disable Force-Touch/3D Touch preview on buttons/links #95

Closed
michiels opened this issue Mar 19, 2017 · 4 comments
Closed

Disable Force-Touch/3D Touch preview on buttons/links #95

michiels opened this issue Mar 19, 2017 · 4 comments

Comments

@michiels
Copy link

In my Turbolinks iOS view when someone force touches on a button or link it first opens the preview and then goes to the link in external Safari browser. Can I disable this behaviour? It causes the app experience to break/give a less native experience.

According to https://developer.apple.com/reference/webkit/wkwebview/1415000-allowslinkpreview this behaviour is off by default, but this doesn't seem to be the case for Turbolinks iOS.

Does anyone know what's up?

@benreyn
Copy link

benreyn commented May 2, 2017

I just discovered this same thing is happening for our app. It doesnt look like the Basecamp app does this, meaning that there is some way to turn it off. (I work on our rails app, not the native app, so this may be a well known option to turn off for ios devs)

It also looks like the basecamp app has some special interactions on some links with force touch that I really like.

@zachwaugh
Copy link
Contributor

In iOS 10, there is a WKUIDelegate method to disable this, which is what we do in Basecamp:

func webView(_ webView: WKWebView, shouldPreviewElement elementInfo: WKPreviewElementInfo) -> Bool {
    return false
}

@benreyn
Copy link

benreyn commented May 2, 2017

Is there any way to turn this off in earlier versions of iOS? Looks like our app is 9.0 or higher.

@zachwaugh
Copy link
Contributor

According this this WebKit post, allowsLinkPreview is false by default on iOS 9 and enabled by default on iOS 10:

WebKit supports Peek and Pop as an easy way to preview links. Apps built against the iOS 10 SDK will have Peek and Pop link preview enabled by default, but the feature is not new; since iOS 9, WKWebView clients could opt into Peek-based link previews on 3D Touch-capable devices using the allowsLinkPreview property on WKWebView. When the allowsLinkPreview property is set to true, users can gently press on links to peek them, which loads the link in another view over the app and blurs the app in the background.

So setting allowsLinkPreview explicitly to false should disable on all versions of iOS, but I haven't tested that. I think that would be a reasonable default for Turbolinks.framework. I can't see many cases where you'd want that, and if so, you could override those properties/delegates to turn it back on

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants