Redirect to app play store from html

4

I would like to know how I can open my app directly in the google play store.

It happens that we have an application that has a WebView pointing to the site of our company, on the site of our company we are placing the code below (that is a test site), that's where we detect depending on the package if you are using the app, when you detect that you use our app we want to send you an alert message and redirect it to the play store app so you can download a new app from us.

I show my html code to explain myself better.

<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="/global_js/jquery/jquery-1.8.2.min.js">    </script>    

<title>APP</title>


<?php
if($_SERVER['HTTP_X_REQUESTED_WITH'] == "com.ejemplo.cooperativa"){
echo 'estás desde la app';  
//$ch = curl_init("market://details?id=com.ejemplo.cooperativa");
//curl_exec($ch);

echo "   <SCRIPT>window.location.href='https://play.google.com/store/apps/details?     id=com.ejemplo.cooperativa&feature=search_result#?';</SCRIPT>"; 
}

else{
echo 'NO estás desde la app';
}
?>


</head>
<body >

</body>
</html>

I hope it has been understood.

I have the following error:

do not show http://imageshack.com/a/img924/1170/H8Kbqo.png

Thank you in advance.

    
asked by Rodrigo 05.05.2016 в 20:49
source

5 answers

1

The structure is as follows: market://details?id=com.package.tuapp With this scheme Android will open directly in Playstore the detail of your app

    
answered by 05.05.2016 в 20:56
0

I understand that it is best to generate the button and place it inside your html to redirect to Google Play where your application is.

To generate the button you can go to link

    
answered by 05.05.2016 в 21:44
0

But also:

<script>
  window.location.replace('market://details?com.ejemplo.cooperativa');
</script>

It can even be a link:

<a href="javascript: window.location.replace('market://details?com.ejemplo.cooperativa');">
  Ver app
</a>
    
answered by 05.05.2016 в 21:53
0

In your code you have a detail:

<SCRIPT>window.location.href='https://play.google.com/store/apps/details?     id=com.ejemplo.cooperativa

the variable id should not be separated in the url, it should be:

<SCRIPT>window.location.href='https://play.google.com/store/apps/details?id=com.ejemplo.cooperativa

How to open an application from the playstore from a web page.

From a web page you can do it by:

<script>
  window.location.href='https://play.google.com/store/apps/details?id=com.ejemplo.cooperativa';
</script>

or

<script>
  window.location.replace('https://play.google.com/store/apps/details?id=com.ejemplo.cooperativa');
</script>

Another option is using the market:// protocol, but this method only works within an android device either on a web page or a webview.

<script>
  window.location.replace('market://details?id=com.ejemplo.cooperativa');
</script>

You can review the documentation to see more details.

  

From a website:    http://play.google.com/store/apps/details?id=<nombre_paquete>

     

From an Android application:    market://details?id=<nombre_paquete>

Example:

<html>
<head>
    <title>Abrir aplicación Playstore</title>
</head>
<body>
<a href="http://play.google.com/store/apps/details?id=com.ejemplo.cooperativa">Abre con http://<a>
<br>
<a href="market://details?id=com.ejemplo.cooperativa">Abre con market://<a>
</body>
</html>
    
answered by 05.05.2016 в 23:00
-1
<script>
  window.location.href='market://details?com.ejemplo.cooperativa';
</script>

But also:

<script>
  window.location.replace('market://details?com.ejemplo.cooperativa');
</script>

It can even be a link:

<a href="javascript: window.location.replace('market://details?com.ejemplo.cooperativa');">
  Ver app
</a>
    
answered by 05.05.2016 в 21:46