I would like to create a web-page, a page that will redirect to App Store if App is not installed in iPhone, and will redirect to The App if App is installed in iPhone.
I wrote Javascript like below.
function launchApp(){
let URI_SCHEME = 'myapp://';
let APP_STORE_URL = 'https://itunes.apple.com/jp/app/myapp/id111111111';
let userAgent = navigator.userAgent.toLowerCase();
if(userAgent.search(/iphone|ipad|ipod/) > -1){
location.href = URI_SCHEME;
setTimeout(function (){
let aTag = document.createElement('a');
aTag.href = APP_STORE_URL;
aTag.Click();
}, 1200)
}
}
I tried this code, and in iOS Safari, it works as I expected.
However, in iOS Chrome app, it does not work.
To be more specific, when I tap the link button to the page that I am creating, the new tab opens but closes immediately.
Does anyone know why it does not work in iOS Chrome app?
Moreover, does anyone know better solution?
Thank you for your cooperation.
Related
Working with deep linking, I have the code snippet below on my web page.
The code works fine on Chrome but on Safari, I just get a message to say it could not find the deep link without redirecting.
On Chrome, it redirects to the relevant store if the app is not found.
"Safari cannot open the specified address: myapp://
I tried wrapping in a try catch block but to no avail.
Any help is appreciated.
setTimeout(function () {
if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
window.open("http://play.google.com/store/apps/details?id=com.myapp","_top");
}
else if (navigator.userAgent.toLowerCase().indexOf("iphone") > -1) {
window.open("https://apps.apple.com/us/app/myapp","_top");
}
}, 2000);
window.location = "myapp://";
When i try to open a url in android using inappbrowser, the url does not open a shows a blank screen with the url on the top. But when i try to open the same url in chrome it is opening fine and also on ios device it is working fine.
Issue only comes when opening in android inappbrowser.
Is it some javscript issue or something else, i m not able to figure it out.
this is the code which opens the url:
const browser =
this.iab.create('loginDetails.serverURL','_blank','location=yes,toolbar=yes');
you can use this..
String link=URL_LINK;
if (!link.startsWith("http://") && !link.startsWith("https://")){
link = "http://" + link;
}
Uri uri = Uri.parse(link); // missing 'http://' will cause crashed
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
context.startActivity(intent);
We have an app, lets call it: xyz_app for which I have a custom URL scheme in form of xyz_app://.
We are sending an email to the user.
when he clicks on the link, he is suppose to go to the app and in case the app is not installed, our mobile website.
so from the Link in the email, how do I make sure that if the app is not installed, that link should send the user to the mobile website instead ?
The URL scheme works directly only if the app is installed on the iDevice. If not installed then it will throw an error.
1) To implement this functionality you will have to redirect the user to a webpage that will detect if app is installed, from your email link. Something like this www.yourwebsite/detectapp
2) Your detectapp page will have a javascript-
var appstoreFail = "www.your_redirect_website.com";
//Check is device is iOS
var iOS = /(iPad|iPhone|iPod)/.test(navigator.userAgent);
var appUrlScheme = "xyz_app://";
if (iOS) {
// If the app is not installed the script will wait for 2sec and redirect to web.
var loadedAt = +new Date;
setTimeout(function() {
if (+new Date - loadedAt < 2000)
window.location = appstoreFail;
} ,25);
// Try launching the app using URL schemes
window.open(appUrlScheme, "_self");
} else {
// Launch the website
window.location = appstoreFail;
}
I would like to determine an installed app using custom URL scheme on iPhone Safari.
You may believe it is impossible to do this, but JavaScript helped me to figure this out.
<script>(function(){
var fallbackLink = '<?=$info['failed_url']?>'+window.location.search+window.location.hash;
var isiOS = navigator.userAgent.match('iPad') || navigator.userAgent.match('iPhone'),
isAndroid = navigator.userAgent.match('Android');
if (isiOS || isAndroid) {
document.getElementById('loader').src = '<?=$info['scheme']?>://'+window.location.search+window.location.hash;
fallbackLink = isAndroid ? '<?=$info['failed_url']?>' :
'<?=$info['failed_url']?>' ;
}
window.setTimeout(function (){ window.location.replace(fallbackLink); }, 1000);
})();</script>
here is my script.
I already know custom URL scheme of the iPhone application. It successfully launches the application if it exists on the iPhone. However, if the iPhone doesn't have the application, it redirects to a different page.
I put certain code on the failed web page to notice that user doesn't have the application. My plan was perfect until I found this.
The JavaScript redirection works even though the application is launched on iPhone after timeout.
Is there a way to stop JavaScript if iPhone launched application?
Thank you.
You can always cancel the timeout when the window loses focus.
var countdown = window.setTimeout(function (){
window.location.replace(fallbackLink);
}, 1000);
window.addEventListener("blur", function (){
window.clearTimeout(countdown);
}, false);
I'm developing an web app for Windows Phone 7 using jquery mobile.
I want to navigate to a page say index.html to sample.html.
function sample()
{
window.location.href = "Sample.html";
navigator.notification.alert("Navigated);
}
It works fine.
But when a querystring is added with "sample.html?id=123123"
function sample()
{
window.location.href = "Sample.html?id=123123";
navigator.notification.alert("Navigated");
}
This navigation does not work.
Can anyone please guide.Anyother navigation method along with querystring is also welcome.
We can not use a querystring in web application using phonegap for windows phone 7.
Instead we can use Sample.html#12312
What is txt? It looks like it might be throwing an exception when you try to access txt.value, because txt is null. I assume it is a textbox on the page, so you'd have to access it like $("input#txt").val(); instead
In a PhoneGap Windows Phone application it should be like:
document.location = "Sample.html#id=123123";
Or:
window.location.href = "Sample.html#id=123123";