0

I feel like I'm going a little crazy. Everything I see on deep links and opening up app store links tells me this should be working, but it's not.

Our App is basically a wrapper around the UIWebView, with most of the functionality residing in our webpage. I'm wanting to link to the App Store from our website and have it pull it up. If I do it from external browser or anything else, it seems to work. When I do it from a link on our webview, I get the App Store Preview in our WebView. Not helpful.

Here's the link in our HTML:

<td style="width: 50%; padding: 5px"><a href="https://itunes.apple.com/us/app/ab-classic/id343200656?mt=8"><img style="width: 100%" src="~/App_Themes/common/images/mobile/AppStoreBadges/apple-app-store.png" /></a>

Looks like they've done away the old itms: deep linking in favor of the universal links. I could intercept the WebView redirect to their site, and then kick it out from a Swift standpoint, but I wanted this to work on my current code and not make a change just to handle itunes links.

Brent
  • 79
  • 6

1 Answers1

2

You need a navigation delegate. For UIWebView, your delegate would implement webView(_:shouldStartLoadWith:navigationType:). When you get this link, you would return false and instead pass it open to the runtime with open(_:options:completionHandler:).

matt
  • 447,615
  • 74
  • 748
  • 977
  • I was hoping that was not the answer, but I could see that being the case. I have delegates for other sites I added, but figured the App Store of all things would just work. – Brent Aug 14 '18 at 18:27
  • I'm not sure what "just work" means. Deep linking _always_ works by calling `open(_:options:completionHandler:)`. — Oh, I see what you mean; you mean it should work thru a special scheme and now it doesn't. – matt Aug 14 '18 at 18:33
  • Quite a lot of discussion here: https://stackoverflow.com/questions/35522618/universal-links-on-ios-vs-deep-links-url-schemes – matt Aug 14 '18 at 18:38
  • And some additional insights here: https://stackoverflow.com/questions/433907/how-to-link-to-apps-on-the-app-store – matt Aug 14 '18 at 18:39
  • By "always works", I would think, any link you click in a browser, app, email, text, etc would follow the deep linking. What I found when implementing it myself, is that links in emails, text, or calendars just worked, but plugging it directly into the browser didn't work for universal links. I had to create a deep link as well on my site to redirect it from the browser to my app. Basically, the universal links ( taking over https://mysite ) isn't across the board, only in certain circumstances. I know that probably sounds confusing, but it was confusing for me as well implementing – Brent Aug 14 '18 at 18:40
  • Sorry, but I have one more little point: I think you can make the `itms-app` scheme work in your web page, if it doesn't already, by switching to WKWebView (like you're supposed to) and implementing a custom scheme handler. – matt Aug 14 '18 at 18:41
  • Good callout. I went checking, I actually am (surprisingly) using the WKWebView. Sounds like I just have to make the delegate catch my URL change and pop it out to external. Catch22 on my part. For my old version of the app to point me to iTunes to update, I need to udpate my app. Oops. Guess I'll be covered for next time. – Brent Aug 17 '18 at 13:56