Link Unshortener for iOS

May 19 2020 by Jeff Johnson

This is not an announcement of Link Unshortener for iOS. Unfortunately, it's the opposite. I did begin development, but I've determined that unless a pleasant surprise (miracle) occurs at WWDC next month, Link Unshortener for iOS is not a viable product, due to iOS API limitations.

Link Unshortener is a bit unusual in that the main way of using it is not by launching the app directly. On macOS there are several ways to access Link Unshortener indirectly: the Share menu in other apps, the system Services menu, and StopTheMadness via its Open Link with contextual menu item or its Web URL Rules. Indeed, Link Unshortener was intended primarily as an accessory to StopTheMadness. Since Safari extensions do not exist on iOS (which makes so-called "desktop-class browsing" on iPad a sick joke), Link Unshortener would be disadvantaged from the start. The system Services menu doesn't exist on iOS either. Thus, the main access point for Link Shortener on iOS would be the Share menu. On both iOS and macOS, the Share menu functionality is implemented by a share extension embedded within the app.

The share extension embedded in Link Unshortener for Mac has no user interface of its own. The share extension simply opens the Link Unshortener app and passes along the shared link. This is accomplished with the NSWorkspace API on macOS. However, NSWorkspace doesn't exist on iOS. You have to use the UIApplication API on iOS in order to open a URL externally. This works fine from the Link Unshortener for iOS app, but it doesn't work from the Link Unshortener for iOS share extension! According to Apple's App Extension Programming Guide, some API are unavailable to app extensions, including all UIApplication methods. Sadly, there's no supported way for a share extension on iOS to open a URL in an app. Some developers have suggested to me that there's an unsupported way to bypass this limitation, and while that might be fine for a minor feature, the share extension is the heart of Link Unshortener. I have no desire to gamble an entire app on Apple overlooking my misuse of their API. App Review could decide at any time to reject or remove my app, in which case I'd be completely stuck. On iOS, developers have no option for selling an app outside the App Store, so we're bound by Apple's arbitrary rules and whims.

I can recreate most of the iOS app's functionality within the share extension, even the user interface. But the inability to open a URL is a showstopper. The "funny" thing is that I can show hyperlinks in the share extension via UITextView, and although clicking on the links does nothing — presumably for the same reason UIApplication doesn't work — pressing down on a link does bring up the Share menu. Sharing from within a share extension! The Share menu contains an item to Open Link in Safari, which again doesn't work. Strangely, though, the Share menu also shows a web preview of the linked site, and clicking the web preview does open the link in Safari! I'm not certain why there's a difference, but I'd guess it's because the WebView is running in a different process than the share extension (which is itself running in a different process than the "host" app, e.g., Safari) and thus has different capabilities. So technically, there is one obscure way to open a URL from a share extension, but it would still be a terrible, haphazard, mostly incomprehensible experience for the user.

Without the ability to open a URL from the share extension, Link Unshortener for iOS would have to rely on copy and paste for all of its functionality. This would be especially unpleasant on iOS, because of the awkwardness compared to macOS. Switching between apps tends to be more difficult on iOS for several reasons, for example, the significantly smaller Dock that only fits a few apps. Even pasting can be more difficult on iOS, if you have to deal with pasting over existing text. The worst part, however, is that every Link Unshortener customer would email me and request that they be able to open the URL directly instead of just copying and pasting it. Customers don't understand the technical API limitations, and in fairness, they shouldn't be expected to. I don't want that support burden (or the predictable low App Store ratings when customers are frustrated).

This blog post was a long-winded way of saying that Link Unshortener for iOS is sadly not in the cards at the moment. Circumstances could change in the future, but I have no current plans to continue development of the iOS app. I just wish that Apple would impose fewer arbitrary restrictions on third-party developers. (It's worth noting that Apple does not impose such harsh restrictions on its own software.) If what I do is fine on macOS, why is it forbidden on iOS?

Jeff Johnson (My apps, PayPal.Me)