Tuesday, April 19, 2022

Disabling Universal Links

Buzz Andersen:

Am I the only one who finds Apple Universal Links to be, like, an enormous pain in the ass?

Paul Haddad:

As much as Apple makes a big deal about privacy, the fact that you can’t globally disable universal links feels like an info leak.

Tap on an Amazon link a friend sends you on iMessage with the Amazon app installed, now Amazon knows you are interested in that product.

I like the idea of Universal Links, but in practice they always seem to get in my way.

On iOS, I often end up viewing a tweet in the official Twitter app, even though I would prefer Tweetbot or even Safari. I can’t prevent this by uninstalling the Twitter app because I need it for authentication.

On macOS, clicking on a WWDC video link in Safari opens the Developer app, which I never want.

Ryan Nystrom:

[Is] there a way for users to opt out of Universal Links for a single app? Either via system settings or something developers can do in app.

In Safari for Mac, you can use the contextual menu to tell it to open in Safari instead. But this is a bad solution because you have to know that what you are clicking is potentially a Universal Link and remember to do it. And there’s no option that I could find to make it remember your preference. One workaround is to use a different browser instead of Safari.

On iOS, I think you used to be able to tap and hold to change the default. But now it seems to behave like on the Mac. And the case of WWDC videos is extra confusing because on iOS the default is the opposite—to use Safari even if the Developer app is installed.

The other annoying part is that when I finally do get to see the Universal Link’s content in Safari, it sometimes fills a good portion of the screen with a banner recommending that I open the app instead.

Jeff Johnson:

You can’t tell Safari to just STFU about the Twitter app.

[…]

My final, “insanely devious” idea (as someone called it) was to create a fake Twitter app. When there are multiple apps installed on your Mac with the same bundle identifier, macOS tends to prefer the one with the highest version number. So I opened a new Mac app project in Xcode and gave it the bundle identifier maccatalyst.com.atebits.Tweetie2, matching the real Twitter app. I gave the new app the bundle version 1000.0.0, which was arbitrary but likely higher than anything you’ll ever see in the real Twitter app, currently at version 8.18.1. And I added an AppIdentifierPrefix key with the string “8248RGMF2D.“ to the new app’s Info.plist file, again matching the real Twitter app. The critical difference between the real Twitter app and the fake Twitter app is that I did not add com.apple.developer.associated-domains to the fake app’s entitlements. The associated domains in the real Twitter’s entitlements indicates that it supports Universal Links (applinks). You can see its entitlements with the command codesign --display --entitlements - /Applications/Twitter.app in Terminal. My theory was that Safari would hopefully look at the fake app with the higher version number instead of the real app with the lower version number, and decide that Twitter did not actually support Universal Links.

It appears that my theory was correct! You can download my new app StopTheTwitter, which is notarized for macOS Catalina.

Previously:

On the flip side, I’m super sad that so many apps intercept universal links and throw me into a web view just to keep me contained

This should be a built-in part of Settings for each app so that the user can choose and also see what the current setting is.

I did a study of Universal Links last summer, and found them to be plain broken on macOS with SwiftUI app lifecycle. Plus I could not figure out “developer mode”.

Universal Links on the Mac operate via the swcd (Shared Web Credentials Daemon, /usr/libexec/swcd) process.

[…]

The solution to the problem is to deny swcd with Little Snitch.

However, I’ve already allowed the Universal Link, which is still in effect. I also need to undo the damage of allowing it.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f -R /Applications/Twitter.app

Previously:

3 Comments RSS · Twitter

Nice! I did a chmod to twitter.app so it wouldn't open unless I changed it back.

Might be able to help a little -- https://sindresorhus.com/velja

In particular the settings - apps tab.

@rajs Thanks for the suggestion, but neither the Apps tab for Twitter nor the Rules tab for Ivory seemed to work for me to redirect Universal Links back to Safari.

Leave a Comment