Reputation: 21
I created a new quasar project, added cordova and played around a little bit.
Everything is working, I can deploy the app on my phone and run it in the emulator.
Right now, I need to get some device information and I wanted to use cordova-plugin-device for that. The plugin is loading, like every plugin I installed. I can see it in the developer window (safari) within the iOS xCode emulator.
Now, I try to get the device information, like it is described in the documentation:
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-device/index.html
Something like that in the App.vue:
mounted: function () {
document.addEventListener('deviceready', this.onDeviceReady, false)
},
methods: {
onDeviceReady: function () {
console.log('cordova', cordova)
console.log('device', device)
}
...
But the following error always appears in the console:
error ‘device’ is not defined no-undef
How can I solve that? I removed the platform already and re-added it.
I am out of ideas and cannot find anything related on the internet.
Thanks in advance Cheers Basti
Upvotes: 1
Views: 1149
Reputation: 4428
Try this
var Type = (navigator.userAgent.match(/iPad/i)) == "iPad" ? "iPad" : (navigator.userAgent.match(/iPhone/i)) == "iPhone" ? "iPhone" : (navigator.userAgent.match(/Android/i)) == "Android" ? "Android" : (navigator.userAgent.match(/BlackBerry/i)) == "BlackBerry" ? "BlackBerry" : "null";
alert(Type);
Upvotes: 0
Reputation: 21
With the help of the quasar community, I could already solve my problem.
The magic words are: window.device
.
Upvotes: 1