将用户重定向到iTunes应用商店或Google Play商店?

Flo*_*ian 22 iphone android facebook ios

我正在寻找一个简单的解决方案来发布我的应用程序的一个链接,例如在Facebook上,如果用户使用移动设备访问它,它应该自动重定向到正确的应用程序商店.否则,应将用户重定向到我的网站.

iOS应用程序:http: //itunes.apple.com/de/app/dawawas/id588285122

Android应用:https: //play.google.com/store/apps/details?id = de.conceptspace.dawawas.greenturtle&hl = zh-CN

网站:https: //www.dawawas.com/

bri*_*fit 34

如果你想自己滚动而不使用第三方,那么还有一个Javascript解决方案:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
<script>
function getMobileOperatingSystem() {
  var userAgent = navigator.userAgent || navigator.vendor || window.opera;

      // Windows Phone must come first because its UA also contains "Android"
    if (/windows phone/i.test(userAgent)) {
        return "Windows Phone";
    }

    if (/android/i.test(userAgent)) {
        return "Android";
    }

    // iOS detection from: http://stackoverflow.com/a/9039885/177710
    if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
        return "iOS";
    }

    return "unknown";
}</script>

<script>
function DetectAndServe(){
    let os = getMobileOperatingSystem();
    if (os == "Android") {
        window.location.href = "http://www.Androidexample.com"; 
    } else if (os == "iOS") {
        window.location.href = "http://www.IOSexample.com";
    } else if (os == "Windows Phone") {
        window.location.href = "http://www.WindowsPhoneexample.com";
    } else {
        window.location.href = "http://www.NowherLandexample.com";
    }
}
</script>
</head>
<body onload="DetectAndServe()">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)


Str*_*der 13

你的意思是这样的?

如何使用onelink.to

onelink.to是链接到您的应用程序的简单而轻松的方式!

只需将URL添加到您的应用程序中,我们将确定每次有人使用您的onelink.to地址时使用的URL.

您可以免费使用onelink.to 用于私人和商业用途.我们没有计划改变这种情况.

您还可以为您的网站添加后备网址.

希望这能帮到你.

  • "目标不是使用第三方",你在哪里读到这个?他想要一个简单的**解决方案,所以第三方可以成为他想要的解决方案. (5认同)

Chi*_*rry 11

在PHP中,您可以使用以下内容:

<?php

$iPod    = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
$webOS   = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");

//do something with this information
if( $iPod || $iPhone ){
    //browser reported as an iPhone/iPod touch -- do something here
    $string = "Location: <<your itunes app link>>";
    header($string);
    die();
}else if($iPad){
    //browser reported as an iPad -- do something here
    $string = "Location: <<your itunes app link>>";
    header($string);
    die();
}else if($Android){
    //browser reported as an Android device -- do something here
    $string = "Location: <<Google Play Link>>";
    header($string);
    die();
}else if($webOS){
    //browser reported as a webOS device -- do something here
    $string = "Location: <<Your Page link>>";
    header($string);
    die();
}else{
    //browser reported as PC -- do something here
    $string = "Location: <<Your Page link>>";
    header($string);
    die();
}


?>
Run Code Online (Sandbox Code Playgroud)

您可以分别使用iTunes或Android的链接:

itms-apps://itunes.apple.com/app/<<App ID>>
market://details?id=<<Package id>>
Run Code Online (Sandbox Code Playgroud)

我不记得来源,但至少它适用于我在Whatsapp等其他应用程序中共享,但遗憾的是它不适用于Facebook.

Facebook中的问题是他们在重定向路径上使用最终链接的元数据,并且链接指向GooglePlay商店.


小智 7

我们正在寻找一种解决方案,将用户引导至正确的 App Store,并携带额外的元数据,以便在 App Store 安装后启动应用程序时,它会知道用户来自哪里并启动特定的活动。

因此,如果像我这样的其他人阅读这篇 Stack Overflow 文章,获得 OP 要求以及携带额外元数据(并跟踪所有转换)的额外好处的提示是查看 Firebase 动态链接:https:// firebase.google.com/docs/dynamic-links


小智 3

您可以使用http://toSto.re立即创建 iTunes 和 Google Playstore 的短链接。

只需选择一个名称并输入不同的应用程序商店网址,您就会得到一个链接,例如 toSto.re/facebook,它会根据用户代理自动定向到正确的网址,甚至支持 Google Analytics 迭代以获取某些统计数据。