You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 informationif(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.
The text was updated successfully, but these errors were encountered:
Hi there,
I noticed in the documentation for the Device JS API page there's an
if
statement checking for the existence ofcordova
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
withwindow.cordova
, so the code will become this:To avoid confusing people who don't know JavaScript, it might be worth replacing the references to
cordova
withwindow.cordova
in the Reactive and Mobile documentation.Edit: added link to documentation where I noticed the issue.
The text was updated successfully, but these errors were encountered: