Вопрос

I am writing a hybrid app for Android/IOS, with rendering on web-kit, I want to use the same views (HTML5) for my mobile web app.

Is there a way to identify through jQuery or plain javascript, whether the loaded thing is an Hybrid App or Mobile web, so that I can conditional show hide components for Mobile web and Hybrid app.

Это было полезно?

Решение

FYI, nowadays we can write our mobile apps (hybrid) using HTML, CSS and JS. And wrap it in a wrapper (android/ios), sometimes using Phonegap.

You approach looks good but lets try another approach. why do not you set some kind of flag in your codebase that will help you to figure out whether your app is running inside webview or in the browser itself?

Hope this would help.

Другие советы

I use this snippet that works for me

function isApp() {

var app = document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1;
  if (app) {
      // PhoneGap application
      //alert("U're using cordova");
      return true;
  } else {
      //alert("U're using browser");
      return false;
  }
}

Hope it helps you. Regards.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top