Open android app from browser when page loads - javascript

I want to open my app when user goes for example:
www.example.com/myApp
open app
and if i click this link, it works,
but i want my app to be opened without click, when page loads.
I have tried:
window.onload = function () {
window.location.replace("intent://something#Intent;scheme=myapp;package=com.example.myapp;end;");
}
and
window.onload = function () {window.location.href = "intent://something#Intent;scheme=myapp;package=com.example.myapp;end;";}
even
window.onload = function(){document.getElementById("a").click();}
but none of these work.

Folks who are having the same issues on universal linking where they need to app link without user action.
we have not been able to app link without user interaction. Google chrome does block the app linking from the URL.
Hence request you all to take user interaction based approach.which is 100% valid approach for universal linking on all the device OS Android or iOS.

Related

How to hide navigation bar in pwa when opening external link

what is the best possible solution to hide navbar with three dots when opening external website in PWA app?
The case is that the app is already build, but when clicking the external link I wanted to open as standalone mode in app, so the only possible way to go back will be by using swipe gesture on android ;)
That is the code used for open this:
class="space-button"
on:click={() => {
if (depObj.viewUrl) {
window.location.href = depObj.viewUrl;
}
}}
>
BUTTON TO OPEN EXTERNAL LINK
</div>
In your webmanifest.json the scope attribute defines what websites belong to your app. If the user navigates to a website not covered by the scope, it will be opened outside of the application window.
See more here: developer.mozilla.org

Redirect To Dynamic Link In Javascript Not Working

I am using firebase dynamic links to link my website to my app. I use the longer link (https://example.com/deeplink/?link=example.com/foo?id=1&apn=com.examle.app) so that I can pass parameters into my app through the link. I want to keep this shorter, so I have a website (https://example.com/getfoo?id=1) which sees if the user is on android, and if they are it'll redirect them to the deep link. But it is not redirecting. I am sure it gets the id, and I'm sure it knows whether or not they are on mobile.
I have tried changing the redirect to other pages, and my own website, and it works. But when I try to redirect to my dynamic link, it just doesn't redirect at all. It acts like the redirect doesn't exist.
Code: (hosted on /foo)
const ID = getParameter('id');
if(isMobile()) {
var confirm = confirm("You are on mobile. Would you like to open this page in the app?");
if(confirm) {
var dynamicLink = "https://example.org/deeplink/?link=https://example.org/foo?id=" + prayerID +"&apn=org.example.app"
window.location.replace(dynamicLink);
}
}
When you press OK it should redirect you to the dynamic link which should open the app. Instead on mobile it just leaves you on the /foo webpage. What am I doing wrong?

google chrome AddressBookUrlForwarder pop up when url link clicked

i have the user click on the icon. If the user is on a desktop they will get redirected to the webpage lets use facebook as an example. If the user clicks the icon when in mobile they will be directed to the facebook app but if they do not have it they will go to the webpage via there browser.
The mobile view is fine but on the desktop when the link is clicked this keeps popping up(in chrome).if i use a href tag it doesnt pop up. From a user experience perspective this is annoying. Is there a way to fix this.?
javascript code im using to direct them to webpage via browser or open app if they have it
function goToURL() {
setTimeout(function () { window.location = "https://www.facebook.com/page/"; }, 8000);
window.location = "fb://profile/page";
}
So i managed to get rid of the problem. I just took away the
window.location = "fb://profile/page";
On the same page I have instagram and soundcloud. For these two i just put in the url for the page and on mobile they open in the app instead on the mobile web browser. For facebook however it does not have this feature(idk why?) it opens up safari and goes to the mobile facebook website. A work around i found was to use a deep link such as URLgenius and it worked. If anyone has ran into this issue i hope it helps you out.

Can't Open URL in Safari in UI5 app in Cordova Container

I have developed an SAPUI5 app that works on browser, and I am trying to make it an iOS build by wrapping it in a Cordova container.
In one of the pages of the app, I defined a button that when it is clicked, it should open up a separate Safari window (see code below), however, when I test this functionality, it opens the URL directly in the application.
Therefore, if I want to go back to the home page of the app, I need to kill the app and restart it.
I have this same problem with and without the inappbrowser Cordova plugin.
Does anyone have any ideas of a possible resolutions for this? Appreciate the help!!
var button= new sap.m.Button ({icon: "sap-icon://meal"
, press: function (oEvent)
{window.open ('MYURLHERE', '_system')}})

Redirect page to div with Javascript using Jquery Mobile Multi-page template

I have an android app, and I want to add a function to check if the user is connected to the internet. If they are not, I display an alert and then want to redirect them away from a 'page'. The problem is however that I am using a Jquery Mobile Multi-Page template. So technically I am not redirecting to a page, it is a div. My code is as the following:
networkState = navigator.network.connection.type;
if (networkState == Connection.NONE)
{
alert('No internet connection detected');
window.location.href = "#seconddiv"
};
However this does not work, and if I set it as index.html it goes right back to the start of the app, which is not acceptable. Does anyone know how to just get it to redirect to a div?
Try the $.mobile.changePage function: http://jquerymobile.com/test/docs/api/methods.html
$.mobile.changePage($("#seconddiv"));

Categories