Example use cordova plugin
-
Thank you @rstoenescu all right here.
-
@rstoenescu Call the cord this way is correct?
export default {
data () {
return {}
},
mounted () {
document.addEventListener(‘deviceready’, onDeviceReady, false)
}
}
but it does not workshow error: ✘ http://eslint.org/docs/rules/no-undef ‘onDeviceReady’ is not defined
-
@gmferreir1 You don’t need to ensure that device is ready. Quasar takes care of it for you automatically. And anyway registering for that event in a component would be far too late in the life of an app. The error is displayed in your case because you’re registering a trigger with
onDeviceReady
which you didn’t define.Bottom line, you don’t need to register the event.
-
I need a simple example of an implementation. I did not find anything with Quasar, nor in the issues, nor here in the forum.
-
@rstoenescu Thanks, helped a lot, now I understand how it works. I was able to implement.
@xereda follows implementation cordova camera, worked form me. Do not forget to add the plugin.
Then run, quasar build, after cordova buildexport default {
data () {
return {}
},
methods: {
test () {
Dialog.create({
title: ‘Warning’,
message: ‘You are about to run out of disk space.’,
buttons: [
‘Cancel’,
{
label: ‘Empty Trash Bin’,
handler () {
// empty the trash bin, yo
}
}
]
})
},
onDeviceReady () {},
getPicture () {
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
saveToPhotoAlbum: true
})
function onSuccess () {
alert(‘success’)
}
function onFail () {
alert(‘Failed’)
}
}
},
mounted () {
document.addEventListener(‘deviceready’, this.onDeviceReady, false)
}
} -
Build your app just like any normal site. Make a build with Quasar CLI, wrap it with Cordova, learn Cordova CLI to make an executable for your specific platform(s) and just run it on your phone. There’s nothing specific that you need to do for Cordova. That’s one of the main power of Quasar. Help me understand what exactly you need. I just want to make you click to see the big picture, make you have that “A-ha!” moment. Quasar deals with lots of optimizations for your code so you won’t have to.
-
@rstoenescu said in Example use cordova plugin:
Build your app just like any normal site. Make a build with Quasar CLI, wrap it with Cordova, learn Cordova CLI to make an executable for your specific platform(s) and just run it on your phone. There’s nothing specific that you need to do for Cordova. That’s one of the main power of Quasar. Help me understand what exactly you need. I just want to make you click to see the big picture, make you have that “A-ha!” moment. Quasar deals with lots of optimizations for your code so you won’t have to.
So I have direct access to the “navigator” object?
-
@gmferreir1 again, no need to deal with onDeviceReady event. That is triggered way way before anything is drawn on the screen. Quasar and Vue itself couldn’t have even initiated if Quasar didn’t used that trigger when App starts. Please read about it in Cordova docs and you’ll understand why.
-
@xereda yep. Here’s a basic example with barcode scanner cordova plugin from quasar play: https://github.com/quasarframework/quasar-play/blob/dev/src/components/play/play-url-list.vue
-
@rstoenescu said in Example use cordova plugin:
@xereda yep. Here’s a basic example with barcode scanner cordova plugin from quasar play: https://github.com/quasarframework/quasar-play/blob/dev/src/components/play/play-url-list.vue
How do I simulate this? Without having an Android device here?
-
@rstoenescu Now I understand completely, thank you very much for your time. The framework is show
-
@xereda android emulators. I’m not near a laptop but if you got android sdk installed and configured with an emulator, “cordova run” should trigger it. Note that you need an actual phone for some plugins like barcode scanner since the emulator can’t emulate taking photos with the camera, obviously.
-
@rstoenescu I’m trying to emulate, but the app gets black screen. I’ll search on …
-
@xereda said in Example use cordova plugin:
@rstoenescu I’m trying to emulate, but the app gets black screen. I’ll search on …
-
@xereda huh? Where did this come from? I don’t think we are on the same page… I’ll show you tomorrow
-
@rstoenescu from your example you are accessing cordova plugins via
cordova
object , why ? if we were to eslint this will bring errors cordova not found ? right ? and in above example of camera plugin then from cordova docsCAMERA
object will be undefined , yes ? so how would we solve this please ? -
- Accessing cordova plugins through
cordova
because this is how they are supposed to work. Has nothing to do with Quasar, but with cordova-lib. - Eslint rules (from
.eslintrc.js
file) hascordova
specified as exception so it won’t signal any errors. - You say “if we were to eslint”… Please do lint your code! It makes it all better and you can capture some errors at compile time
- Regarding
Camera
--> good question. Ask cordova owners (or camera plugin owner) a question about this.
Cheers,
Razvan - Accessing cordova plugins through
-
cordova-plugin-datecs-printer-qr
cordova plugin add cordova-plugin-datecs-printer-qr
not working help me. example quasar-play qr not worked fixed config options ??? -
cordova-plugin-datecs-printer-qr
quasar play to quasar build, cordova run android not worked cordova plugin
help me plugin, config or options ???