Trying to use the plugin, but when running on android device it says that the plugin is not installed
cordova -v):cordova platform ls):
Building a Ionic 3 application, I have followed the steps to use the plugin:
ionic cordova plugin add cordova-plugin-mauron85-background-geolocation@alpha
npm install --save @ionic-native/background-geolocation@4
and when trying to run the app in an Android device, message error plugin_not_installed is shown
Show an alert with the BackgroundGeolocationResponse
plugin_not_intalled error message
I am trying other versions of the plugins and the new plugin @mauron85/cordova-plugin-background-geolocation
1.
2.
3.
4.
this.platform.ready().then(() => { logic plugin code}
Any solution?
You are installing version alpha, install https://github.com/mauron85/cordova-plugin-background-geolocation
@anRoswell yeah, i'm following the docs from ionic framework, https://ionicframework.com/docs/v3/native/background-geolocation/
You have to install this package https://www.npmjs.com/package/@mauron85/cordova-plugin-background-geolocation and uninstall cordova-plugin-mauron85-background-geolocation@alpha
Or just follow this https://ionicframework.com/docs/native/background-geolocation. Despite is Ionic 4, it works in Ionic 3
This one https://www.npmjs.com/package/cordova-plugin-mauron85-background-geolocation is deprecated
Try installing exact version with:
cordova plugin add @mauron85/cordova-plugin-background-geolocation@^3.1.0
Also I believe there is still issue with scoped packages in cordova. Meaning that when you create platform with cordova platform add it may install also non scoped package cordova-plugin-background-geolocation. It's different package, so beware and remove it from package.json.
The best way to avoid this, is to add plugin in config.xml with spec declaration. Check https://github.com/mauron85/cordova-plugin-background-geolocation-example/blob/96b0497013f56515c2ab84a16eacceeb4826c31a/config.xml#L50
Thank you @mauron85 for your answer, i see there are an actualization about the plugin 3.1.0, i going to try you suggestion
Yes, the problem seems to be the scoped package, thanks for pointing that out @mauron85 . It didn't work for me to add it in config.xml because the plugin in package.json kept changing back to cordova-plugin-background-geolocation insteado of @mauron85/cordova-.... So what finally worked for me was adding the plugin directly in package.json so the correct plugin gets installed when adding or preparing the platform.
// package.json
{
"@mauron85/cordova-plugin-background-geolocation": "^3.1.0",
"cordova": {
"plugins": {
"@mauron85/cordova-plugin-background-geolocation": {}
}
}
}
After adding a platform, the old package keeps being added to the package.json but that doesn't seem to interfere so far.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.
Most helpful comment
Try installing exact version with: