Closed Trauck closed 6 years ago
The plugin is available at window.BackgroundGeolocation
as documented in README.
Show me your:
$ cordova plugins
Yes, i read that then i wanna change it but it doesn't work.. I can't instal the right version in the bash.
You are using the wrong plugin.
$ cordova plugin remove cordova-plugin-background-geolocation
$ cordova plugin add cordova-background-geolocation-lt
Oh yes sorry, i didn't see there is a new version of this plugin. I'll try it.
Thank you.
Well, after doing all the required installations, i end up with the same problem: bgGeo is undefined.
Said , bgGeo is undefined line 147.
I must have forgotten to put a variable in the right function or not called a necessary script ..
Remove / re-add platforms
Remove / re-add plugin.
$ cordova platforms
Done, but now should i make someting else or i could add the previous code in my map.js (javascript file linked to my html) ?
I don't understand your question. I asked you to show me the following information:
$ cordova platforms
This is my platforms : (sorry my browser didn't refresh).
The plugin is not yet ready for cordova-android@7.0.0
$ cordova platform remove android
$ cordova platform add android@6.4.0
And it only works on device or we can test it on browser like the last version of background geolocation ?
The plugin does not exist in browser. The plugin implements native location and motion apis (accelerometer, gyroscope, compass).
The browser does not have these apis. Just like the browser doesn't have a Camera API.
You must test on device or sim.
So, i am trying on my device and at launch, this message appears: "Licence Validation Failure BackgroundGeolocation is running in evaluation mode."
Is this the key license in the config.xml file. If that's it I do not have an android key, and I'm a student, so this is not a commercial application and I do not intend to pay for a license.
You cannot use Android without purchasing a license key.
Android will work only in DEBUG builds, so that you can evaluate the plugin before purchase.
Android will not work in RELEASE builds without purchase.
The problem here is that I test my application on my phone that is connected to my pc .. So I can not even test without a license. Otherwise, the problem seems solved, I will see what I will do with the android license. Thank you.
The message "Licence Validation Failure BackgroundGeolocation is running in evaluation mode." is fine.
This means the plugin is running in DEBUG build and is fully operational. It's running in evaluation mode so that you can evaluate the performance of the plugin before purchase.
And how do you access this evaluation mode? I just use $ cordova run android and the application launches on my phone. (I'm sorry for the time I take you, especially for beginners questions, I'm just starting after some project done)
Just don't worry about this. If you see Toast message "Licence Validation Failure BackgroundGeolocation is running in evaluation mode.", you're good to do.
Yes, just run your app with.
$ cordova run android
Yes that's what I'm doing, and just then the message appears.
IT IS SUPPOSED TO APPEAR.
Yes I understand that but so I can not test this plugin without license.
Thank you for all these tips and still sorry for the time used.
YES YOU CAN.
Just IGNORE the message and pretend you have a license.
Well when I come to my page map, nothing happens, like when there is an error in the js.
See Debugging Wiki
There is a lot of information, but the last one is pretty clear.
And i sincerely think that the error comes from the fact that I do not know where to put the part of the code js in my code map.js. And do I call a plugin script in my html page.
Do not post screenshots of logs. Post the text.
I know nothing of your map.js
.
See docs for stopOnTerminate
Hi i tried to integrate with in my hybrid mobile app using ReactJS(not react native), i defined plugin in the config.xml as version below
plugin name="cordova-background-geolocation-lt" spec="^2.11.0-beta.1"></plugin
when i tried to run my application it found the below error on console
Uncaught TypeError: Cannot read property 'on' of undefined at Channel.c (myfileName.js:1921) at Channel.fire (cordova.js:846) at cordova.js:231
@umasankarm
cordova -v
):cordova platform ls
):Plugin version : i mentioned in config.xml -> name="cordova-background-geolocation-lt" spec="2.10.1" source="npm" Platform : Android OS Version : 5.1.1 Device manufacturer : Lenovo A6020a46 Cordova version : i am doing build by Phonegap cloud through Maven
I changed my code like below
var bgGeo = window.BackgroundGeolocation; to var bgGeo = window.plugins.BackgroundGeolocation;
now i get a error as Uncaught TypeError: Cannot read property 'BackgroundGeolocation' of undefined at Channel.c (xxxxx.js:1921) at Channel.fire (cordova.js:846) at cordova.js:231
and i added a
org.webjars.npm cordova-background-geolocation-lt 2.10.1 in pom.xml and import into my main file as
import BackgroundGeolocation from 'cordova-background-geolocation-lt/2.10.1/cordova-background-geolocation-lt';
still its undefined.
The plugin creates the object window.BackgroundGeolocation. See API Documentation for details
The plugin has nothing to do with window.plugins
. It's window.BackgroundGeolocation
in pom.xml and import into my main file as
I know nothing of pom.xml
.
import BackgroundGeolocation from 'cordova-background-geolocation-lt/2.10.1/cordova-background-geolocation-lt';
Where did you get the idea to do this??
If you're using typescript:
let bgGeo = (<any>window).BackgroundGeolocation;
Even i changed my code based on your suggestion but still i got the error
Uncaught TypeError: Cannot read property 'on' of undefined at Channel.c (xxxx.js:1921) at Channel.fire (cordova.js:846) at cordova.js:231
whether i need to add any key in the variable tag at config.xml file under plugin tag for development mode ?
<variable name="LICENSE" value="YOUR_LICENSE_KEY" />
whether i need to add any key in the variable tag at config.xml file under plugin tag for development mode ?
No. The plugin will work in DEBUG builds without a license. Even if you built for RELEASE, the Javascript API is still available at window.BackgroundGeolocation
.
If there is no Javascript API available at window.BackgroundGeolocation
, you do not have the plugin installed.
ok.. then what may be the problem ? We developed a project with ReactJS and build it through phonegap for android and iOS
I do not know.
We can't use the plugin with ReactJs ? for build hybrid application
This is a pure Cordova plugin. It doesn't care about what Javascript framework you use.
The plugin installs its Javascript API at window.BackgroundGeolocation
.
You're not attempting to use the plugin in the browser, are you? The plugin API is only available on Device or Simulator.
actually i installed the apk in mobile and i debugged through Chrome browser by remote device debugging.
In Javascript console
>bg = window.BackgroundGeolocation
Install cordova-plugin-device
and attempt to access it from the Javascript console.
in browser ? or in a application ?
You can't install a Cordova plugin "in the browser".
$ cordova plugin add cordova-plugin-device
ok, i am not using cordova CLI, i will do by adding webjars and will back with good results may be. Thank you
I have never heard of “webjars”.
`
<artifactId>cordova-plugin-device</artifactId>
<version>1.1.4</version>
`
i get in the site https://www.webjars.org/
What makes you think that my plugin is magically available on this “webjars”?
I tryed to put a background geolocation on my app like a sport app. Then i download this plugins and wanna try it on my browser. But this error append : "Uncaught TypeError: Cannot read property 'backgroundGeoLocation' of undefined" on Chrome and "TypeError: window.plugins is undefined[En savoir plus] index.js:229:13" on firefox..
Then i tryed to fix it with using window.Backgroudgeolocation but nothing works. I really don't know what to do..
In addition I looked a lot of forum dealing with this type of problem and nothing works so please do not redirect me.
(Sorry if my statement is not clear, or not very well written)