Error starting native application from web application - iOS - URL not showing

I'm having trouble trying to call my native iOS application from my web application (apple-mobile-web-app-able). Whenever I'm in Safari, I click a button to open my application using a custom URL scheme, this works fine.

However, when I added it to the main screen, I was stuck in an error: URL could not be shown. Redirecting to http or https works fine, but if I call mysupercustomurlscheme: // I get the error message above.

I tried opening it with document.location.href, window.location, etc., but nothing like the trick and I had no ideas.

If anyone has any ideas, I would really appreciate hearing them.

Thanks in advance!

+4
source share
2 answers

Well, here's a somewhat awkward way to do this, but it works and can help some poor soul out there trying to do the same.

Create a simple HTML link first, as it appears that regular HTML links open in Mobile Safari, rather than full-screen in a web application. Link

In redirect.html, you simply redirect the user with simple javascript. window.location = "mysupercustomurlscheme: //"

And this! This, of course, is not the best way to do this, but it is "fair." What I came up with, at least if you have any other suggestions, let me know.

Hope this helps someone!

+1
source

Just wanted to post an example of what Tobias refers to. You need to post on your server and connect to email, social networks, etc. Just replace your application URI with your link in the App Store . Please note that iframe works with a large number of browsers.

<!DOCTYPE html> <html> <body> <script type="text/javascript"> window.onload = function() { // Deep link to your app goes here document.getElementById("l").src = "my_app://"; setTimeout(function() { // Link to the App Store should go here -- only fires if deep link fails window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8"; }, 500); }; </script> <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe> </body> </html> 

So, if the user has your application installed, the connection to the URI will be successful, and you will exist in the browser before the script is launched to redirect to the App Store. If the user does not have your application, the redirect will succeed (after a brief ugly error message). I am a developer at Branch , and we use this, so feel free to ask questions during implementation.

0
source

Source: https://habr.com/ru/post/1391335/


All Articles