Search code examples
wordpressbrowserphonegap-builddetect

Detect phonegap app from wordpress


I am building my app in phonegap. In that app I am calling my wordpress website like window.location="http://www.example.com/";.

Because of window.location my app UI and mobile browser UI are looks same. So I want to detect phonegap app to defer from browser UI. Is there any way to do this.


Solution

  • @JayTh

    Okay. Thanks. VERY GOOD TO KNOW. I spend hours getting beginners to understand issues. You got them.

    Okay, once you load a webpage from a website you are NOT allowed to access any of the Cordova Plugin APIs. However, you can access HTML5 API, like camera and geolocation. Again, you cannot access any of the Cordova Plugin APIs, and any of the 800+ 3rd-party APIs.

    The best way to access the web, is via inAppBrowser. However, the third paragraph states:

    The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs. For this reason, the InAppBrowser is recommended if you need to load third-party (untrusted) content, instead of loading that into the main Cordova webview.

    Apple is serious about their security, so if they detect you are going around this, they may reject your App. Just to be clear on this, there is a new security protocol, which Phonegap Build now requires, and so does Apple. With Phonegap Build, it will create the required Apple ATS entries into the Info.plist.

    So, the best I can do at this point is give you three (3) links.

    1. Top Mistakes by Developers new to Cordova/Phonegap
    2. Core Plugins Setup
    3. HOW TO apply the Cordova/Phonegap the whitelist system

    On 1., you have hit #5 When designing the app, thinks phonegap works like a website or webbrowser.. For the remainder, I recommend just reading the bold sentences.

    On 2., if you want to use the Cordova Plugins, it is best to use the version numbers, if not you will get the latest, and your code may break. This is because now, Phonegap Build now uses NPM for the plugins. And many times bugs fixes get into the plugin, that require the latest compiler - and Phonegap Build is always at least one version behind.

    On 3., You'll need to use the whitelist to apply the fixes that maybe required for any new plugins you are using.

    If you have more questions, I can answer them in comments. If it get too complicate, we can move to Google Group of Cordova/Phonegap - Best of Luck.