If a user is in Safari and clicks on a link that you want to open up the app, and the app is installed, Safari opens a modal that says 'Open ?' with the choice of Yes/No. In the latest update of iOS 9.2, this modal was changed from Javascript blocking to Javascript non-blocking. This means that Javascript continues to run while the modal is up.
To open up the app, you need to safely fall back to the App Store in case the user uninstalled the app since. This is usually done with a setTimeout call like so: window.location = "twitter://"; setTimeout(function() { window.location = "itms-apps://itunes.apple.com/app/id333903271"; }, 500);