Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress Safari can't open the page because the address is invalid? custom app launch

I'm launching a custom app from a web browser on the iphone.

If the app is not installed I am redirecting to a web page on the website.

If it is installed it goes to a specific page on the app

This all works as expected except for about 1/2 a second safari displays a modal window saying the following

Cannot Open Page Safari cannot open the page because the address is invalid.

I know the address is invalid and I would like to know if its possible to suppress the error message in safari.

Thanks

like image 800
nate_weldon Avatar asked Sep 24 '13 15:09

nate_weldon


People also ask

How do you fix when Safari Cannot open a page because the address is invalid?

When you get the 'Safari cannot open the page because the address is invalid' error, there might be some minor issue with the page. To refresh the page on the Safari browser, you can drag the page down and release it. Also, you can tap the refresh button to reload the page.

Why does my zoom say Safari Cannot open the page because the address is invalid?

Possible Causes Safari throws this error when it cannot find the protocol for launching an application; this happens when a program (in this case, Zoom or VSee) is not installed. You'll need to install Zoom or VSee.

Why does my iPhone keep say Safari Cannot open the page?

The first thing that you should do is check your Internet connection as Safari browser shows this error when your iDevice is not connected to either cellular or Wi-Fi network. Check the connection settings and make sure that it is enabled.

What does Safari address invalid mean?

Safari might think the address is invalid because the browser is experiencing problems in the background. This happens occasionally with any app. To fix it, quit Safari then open it and try to load the same page again.


1 Answers

I did find a solution that worked for this. I had it working with a setTimeout of 25ms. But for some reason on a nexus 5 I needed to drop it down to 5ms.

i ended up using the following:

    function goToApp(appLocation, fallbackLocation) {

        setTimeout(function() {
            window.location = fallbackLocation;
             }, 5);
       window.location = "nativeappURL://" + appLocation;
    }

    function goToWeb(baseurl, webLocation) {
        window.location =baseurl + "/"+ webLocation;
    }
</script>

Then I just have two buttons that have an

 onclick="goToApp('appDestination', 'location')"

and

 onclick="goToWeb('webDestination', 'location')"
like image 160
nate_weldon Avatar answered Oct 14 '22 21:10

nate_weldon