GitHub user breautek added a comment to the discussion: cordova.platformId 
returning "browser" on android

`cordova.platformId` is powered by the platform, it's somewhat hard-coded. The 
`cordova.js` file (which is a generated file and each platform has its own 
version) obtains the platform id via it's `platform.js` import.

So the fact that `cordova.platformId` is `"browser"` suggests that you're maybe 
mixing platform files? Everything inside the `platforms/` folder is managed by 
Cordova and in most cases shouldn't be touched.

Also worth making sure you're correctly testing the variable rather than doing 
an assignment. For example:

```javascript
if (cordova.platformId = "browser") { ... }
```

A logical error such as above which might be easy to miss, would do an 
assignment, replacing `cordova.platformId` and then proceed to evaluate whether 
the value is "truthy" (which it is) and thus enter the if condition. If you 
inspect the variable after, it will have the `"browser"` value since the 
assignment has already occurred.

The following would be the correct usage:
```javascript
if (cordova.platformId === "browser") { ... }
```

GitHub link: 
https://github.com/apache/cordova/discussions/493#discussioncomment-10602740

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to