Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open play store app from browser link

From this post I was able to create a functionality to redirect user to android or ios from a single link. However, on detection of Android I want to open the play store with my app shown. I tried the below link on redirect:

window.location.href = "https://play.google.com/store/apps/details?id=com.myapp";

but it opens the play store in the browser itself. I want to open the play store app, I am assuming that my app users will be having the play store app, so I do not want to check whether the play store app is installed or not. I also tried the market link as below

window.location.href = "market://details?id=com.myapp";

but this also does not work. Help appreciated.

like image 254
Hitesh Avatar asked Jun 27 '18 13:06

Hitesh


People also ask

How do I open the Play Store app in my browser?

Open the Play Store in your browser If you are not logged in, you get a Sign in button, and the first thing you must do is to log in with your Google account. Press the Sign in button. The Google account you choose to sign in has to be set up the Android device where you want to install apps.

Can I open Android app from URL?

In this case, use the android:path attribute or its pathPattern or pathPrefix variants to differentiate which activity the system should open for different URI paths. Include the BROWSABLE category. It is required in order for the intent filter to be accessible from a web browser.


2 Answers

I got it working by using the below url on redirect

window.location.href = "https://play.app.goo.gl/?link=https://play.google.com/store/apps/details?id=com.myapp";

When I visit this url from the browser of my mobile, it does not open the play store within browser but opens the play store app instead. This serves my purpose.

like image 176
Hitesh Avatar answered Sep 30 '22 19:09

Hitesh


I think a better way to do this could be

    $(document).ready(function (){
 if(navigator.userAgent.toLowerCase().indexOf("android") > -1){
     window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
 }
 if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
     window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
 }
});
like image 30
Zadiki Hassan Ochola Avatar answered Sep 30 '22 21:09

Zadiki Hassan Ochola