-
Notifications
You must be signed in to change notification settings - Fork 279
Open
Description
Hi there,
I noticed in the documentation for the Device JS API page there's an if statement checking for the existence of cordova before using some cordova specific code that isn't available on web.
The code doesn't work in Chrome (and as such won't work in web apps or the device preview), and instead results in a ReferenceError, like this:
This can be resolved by replacing cordova with window.cordova, so the code will become this:
// get device information
if (window.cordova) {
$public.Device.whenReady().then(function() {
$parameters.DeviceModel = device.model;
$parameters.CordovaVersion = device.cordova;
$parameters.Platform = device.platform;
$parameters.UUID = device.uuid;
$parameters.Version = device.version;
$parameters.Manufacturer = device.manufacturer;
$parameters.IsSimulator = device.isVirtual;
$parameters.SerialNumber = device.serial;
$resolve();
});
} else {
// fallback when testing on desktop browser
$resolve();
}To avoid confusing people who don't know JavaScript, it might be worth replacing the references to cordova with window.cordova in the Reactive and Mobile documentation.
Edit: added link to documentation where I noticed the issue.
Metadata
Metadata
Assignees
Labels
No labels
