0

I am using a custom url to trigger an app in mobile devices. The custom Url wont work if the app doesn't exist. In that case i have to redirect it to alternate url.

i have tried using below timout method in js.

var alternate = function() {

window.location=alternateUrl;

}

setTimeout(alternate , 25);
window.location = customUrl;

note: this works fine in ios but not in android.

Other techniques which i used are ajax request and xml http request.(both coudnt not be used for cross domain requests.)

i have tried using yahoo Api but even that coulnt be used for checking app in mobile using custom url.

Is there any way to find out whether my app exists using custom url schema and redirecting to alternate url if not exists?

user3121587
  • 11
  • 1
  • 3

1 Answers1

0

The only reason this code would work is if the browser took long enough to try and open the page. Then the timeout would be triggered. When the browser navigates away from a page, timeouts from the previous page will no longer be executed, regardless of the next page existing or not.

You might want to load the page in the background with $.get(), and based on the response decide whether you want the user to be redirected there or not.

Eran Boudjnah
  • 1,228
  • 20
  • 22
  • I have to invoke custom URl which is not https request which means i cannot get response code for it. So please advice options for invoking Custom URl. – user3121587 Dec 30 '13 at 07:56
  • Please expand. If it's not https (and not http) - what protocol would you be using? javascript://? My answer only relates to URLs that redirect you to another page. If, for example, you use javascript, your solution may technically work, as you may remain on the same page. – Eran Boudjnah Dec 30 '13 at 08:56
  • I am using custom url to launch an app. For Ex: "readtext://https:host.domain/x.action" This is a cross domain request and also not a https (or http) protocol – user3121587 Dec 30 '13 at 10:28
  • Note my comment on your original question. You have no way (that I know of) of verifying from within normal JavaScript if an app supporting your custom protocol. This leaves you with a solution like the one you used. – Eran Boudjnah Dec 30 '13 at 11:00