My applications are not firing the deviceready event as expected

Struggling to incorporate a cordova plugin into my vue.js project using vue-cordova.

Specifically, I am attempting to utilize the open-native-settings plugin to access device settings on iOS or Android. While it works seamlessly in the demo app provided by vue-cordova on Github, integrating it into my own apps does not seem to trigger the expected event. To address this, I have attempted waiting for the event with:

Vue.cordova.on('deviceready', () => {
  // within this block, checking for required variables
})

and also using:

document.addEventListener('deviceready', deviceReady, false);

Unfortunately, as the event fails to trigger, these approaches yield no results. I find myself unsure of how to proceed to ensure the event triggers so that I can successfully load my desired plugin. As a novice user in this area, I suspect there may be something crucial that I am overlooking.

UPDATE

When introducing vue-cordova into my main.js file, I employ the following technique:

import VueCordova from 'vue-cordova'
Vue.use(VueCordova, {
optionTestKey: 'optionTestValue'
})

Subsequently, when attempting to load the plugins in another view, my approach is as follows:

import Vue from 'vue'
// additional code here
mounted: function() {
this.cloudyConnection();
this.lastUpdateDate = this.getLastUpdateDate();
if (this.cordova.deviceready === true) {
  this.onDeviceReady()
}

After experimentation both inside and outside of the mounted function, utilizing the listed function, I am still unable to achieve the desired outcome.

In addition, I have included

<script src="cordova.js"></script>
in www/index.html per instructions, yet this adjustment has not proved effective.

I extend my gratitude to all who have taken the time to assist me!

Answer №1

Referencing the troubleshooting section of :

“I am having trouble getting my events to trigger”

Although Cordova documentation may not explicitly state it, you must include the following script tag in your www/index.html file:

<script src="cordova.js"></script>

Make sure that cordova.js is loaded before any other scripts, especially vue-cordova, as the latter relies on it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Listen for incoming data from the client in the form of an ArrayBuffer

I have been utilizing the ws library within nodejs to develop a small cursor lobby where players can interact. I have managed to utilize the server to send ArrayBuffers with bit streams to the client and successfully decode them. However, I am encountering ...

iOS - understanding how view controllers can be contained within one another and how autor

My app is designed to support two separate groups of view controllers: those optimized for portrait orientation and those optimized for landscape orientation. I've encountered an issue where presenting view controllers with different orientations res ...

I am having trouble retrieving the array value from the response sent by my server

After receiving a dictionary from my server, when I try to access the values using the following code: {"filters":{ "Facture": [ "Магма (Тычок)", "Тонкий кирпич", "Гладк ...

having difficulties retrieving the attribute value through jquery

I'm currently implementing this method on rowmouseevent. When I use $get(eventArgs.get_id()), the output is: <tr class="normal" data-value="normal" id="ctl00_ContentPlaceHolder1_UserGrid_grdusergrid_ctl00__0" style="height:30px;" /tr> How can ...

"Utilize TipTap with the power of your personalized name

Is it feasible to work around the inability to use the name tag on TipTap for sending data through forms in Laravel? Here's an example of what I have in mind: <tiptap-vuetify v-model="content" :extensions="extensions" ...

Please cease editing once the showmodal form has been returned

In my current project, I am using XE7 on Android v4.4.4. On Form1, I have a TEdit and a TButton. Here are the steps I take: I click on the TButton to display another form (Form2) using ShowModal(...) or Show; I close Form2 by setting ModalResult:= mrOK ...

Transferring information from a JSON object listview to a different activity

Being a beginner in android programming, I am eager to learn new things whenever possible. I have been searching a lot on the website about my query, but it is still unclear to me. My question is how can I send data from a listview populated from an exte ...

Gain access to Google Analytics without the need for page consent by utilizing JavaScript

I am currently building a dashboard with Atlasboard. My goal is to retrieve Google analytics data such as page views, and I plan to run specific queries which can be found here. Is there a method to access my Google analytics data without the consent pag ...

Need to create a callback within a sequence of events?

Is it possible to create a callback chain like this? Widget.update(...).onUpdate(function(data){ console.log('updated'); }); Here is the current code snippet: var Gateway = {}; Gateway.put = function(url, data, callback) { $.ajax({ ...

Is there a technique I could use to create a visual effect like zooming, but without altering the dimensions of the image?

I'm currently working on a project to develop a photo gallery. let img = document.createElement('img') img.src = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/Wikipedia_logo_%28svg%29.svg/1250px-Wikipedia_logo_%28svg% ...

React-Native error message: Promise rejection unhandled - React child cannot be an object

I am experiencing an issue with rendering a list from an array of objects that have the structure provided below. While I have successfully handled the promise and set the data to the state, I keep encountering an error specifically with this array. The da ...

Discover the process of retrieving constant values from a separate Swift class

Is there a way to maintain constant #define values in a Swift class? I have created a Constant.h class within my project, where I defined the constants for screen width and height. Constant.h #define SCREEN_WIDTH_SWIFT UIScreen.main.bounds.size. ...

Stop users from being able to select or highlight text within a content editable div

Is there a method to develop a content-editable div where users are unable to select or highlight content, but can still input information? I'm interested in creating an interface that forces users to delete and enter data character by character, with ...

Downloading files from a Blob in NodeJS: A step-by-step guide

How do I retrieve a file from a BLOB column using NodeJS? Currently, I am utilizing the oracledb library for database operations and my code snippet is as follows: async function getFile(req, res) { let filename = req.params.filename; let file = a ...

Establishing the Default Volume within a script

I'm looking to adjust the default volume of music on my website. Currently, it plays too loudly on load, but I have a slider bar that allows users to change the volume. How can I set the default volume to be 25% of the slider? CHECK OUT MY WEBSITE! ...

Having trouble resolving the error on Android using IntelliJ?

Whenever I launch the project or create a new one, I keep encountering the following error: AAPT err (10539517):I:\AndroidProject\RxPlayer\app\build\intermediates\exploded-arr\com.android.support\appcompt-v7\22 ...

javascript highchart image carousel

I am currently working on a visual chart project using the JavaScript library highchart. After setting up my chart with some dummy data, I am looking to incorporate functionality that allows for triggering an image slide based on the chart data. Specific ...

Moving a div with arrow keys using percentages: A step-by-step guide

I found this amazing script on Stack Overflow that allows me to move elements around the page using arrow keys. It works flawlessly, and I love how it enables diagonal movement by combining different arrow key inputs. Now, my query is whether it's fe ...

Encountering issues with video uploads on Android, whereas image and text file uploads are successful

I am having trouble uploading a video to a PHP server on localhost. While I have been able to successfully upload images and text files using the same code, videos seem to be causing an issue. Can someone please review the code below and let me know what c ...

Changing anchor point in CABasicAnimation using Swift

The following code snippet generates a CALayer (rectangle shape) and initiates its animation from the left to the right upon long-press action by the user ('longPressGestureRecognizer'). Upon releasing the finger, the CALayer animation halts, it ...