0

I want to display a popup if instagram is not installed. I have this code right now:

setTimeout(function () { 
            $.mobile.changePage( "dialog-instagram.html", { role: "dialog" });
}, 5);
window.location = "instagram://media?id=" + element.title;

If instagram is installed on mobile phone, this launch the app and shows the photo I want. If not installed, launch dialog-instagram.html

Thanks ok. The problem is that dialog-instagram.html is always launched. I just want it to launch if app is not opened. I understand why, code is launched with 5 seconds of delay.

Can that be done? How can I know if window.location is succesful or not?

Biribu
  • 3,615
  • 13
  • 43
  • 79

1 Answers1

0

Try increasing the delay time is very short, so you can try increasing it (300ms would be something reasonable). If that doesn't work, try this code (based on this answer):

function startIThrown(){
  document.location = 'instagram://media?id=' + element.title;
  setTimeout(function(){
    if(confirm('You do not seem to have iThrown installed, do you want to go download it now?')){
      document.location = 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=293049283&mt=8&uo=6';
    }
  }, 300);
}

<a href="#" onclick="startIThrown()">Restart iThrown</a>
Community
  • 1
  • 1
Danilo Valente
  • 11,270
  • 8
  • 53
  • 67