android - 使用 nodejs 相应地重定向到 PlayStore 或 AppStore 的公共(public)链接

标签 android ios node.js hyperlink

我需要根据操作系统创建一个重定向到 Android PlayStore 或 Apple App Store 的通用链接。此链接将在浏览器中打开。

最佳答案

您可以使用 javascript 做到这一点:

function changeLink(){
    document.getElementById('link').href= getMobileOperatingSystem();
}

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-link";
    }

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

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

    return "ios-link"; // default
}

关于android - 使用 nodejs 相应地重定向到 PlayStore 或 AppStore 的公共(public)链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44944279/

相关文章:

Android YouTube 集成,删除 YouTube Logo

android - 接收明确的 Intent 。安卓

ios - 应用程序处于后台模式时的文本转语音功能?

mysql - Sequelize - 关联 4 个表

javascript - 是否可以在没有 JavaScript 外部库的情况下处理整数溢出?

javascript - node js - 从回调中获取结果

java - 在 Robotium 中使用资源 ID

安卓 SDK : Get raw preview camera image without displaying it

iphone - ABPersonCopyImageDataWithFormat 删除联系人图片

ios - iOS 中锁定/解锁方向变化