Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

cordova-background-geolocation-plugin don't giving any response in cordova android app

$
0
0

i am using cordova-background-geolocation-plugin in cordova android using voltbuilder the plugin configure successfully but when running code in debug console it is not showing any output

Here is the plugin configuration in config.xml

<plugin name="cordova-background-geolocation-plugin"><variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" /><!-- <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="23+" /> --><!-- <variable name="ICON" value="@mipmap/ic_launcher" /><variable name="SMALL_ICON" value="@mipmap/ic_launcher" /> --><!-- <variable name="ACCOUNT_NAME" value="@string/app_name" /><variable name="ACCOUNT_LABEL" value="@string/app_name" /><variable name="ACCOUNT_TYPE" value="${PACKAGE_NAME}.account" /><variable name="CONTENT_AUTHORITY" value="${PACKAGE_NAME}" /> --><variable name="ALWAYS_USAGE_DESCRIPTION" value="App requires background tracking " /><variable name="MOTION_USAGE_DESCRIPTION" value="App requires motion detection" /> </plugin><platform name="android"><allow-intent href="market:*" /><preference name="AndroidXEnabled" value="true" /><preference name="android-minSdkVersion" value="23" /><preference name="android-targetSdkVersion" value="33" /><preference name="hostname" value="localhost" /><preference name="AndroidInsecureFileModeEnabled" value="true" /><preference name="KeepRunning" value="true"/><edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application"><application android:usesCleartextTraffic="true" /></edit-config><edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity"><application android:exported="true" /></edit-config><edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/uses-permission" xmlns:android="http://schemas.android.com/apk/res/android"><uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <uses-permission android:name="android.permission.ACTION_CREATE_DOCUMENT" /><uses-permission android:name="android.permission.ACTION_OPEN_DOCUMENT" /><uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.POST_NOTIFICATIONS" /></edit-config><preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/icon.png"/><icon src="resources/android/ldpi.png" density="ldpi" /><icon src="resources/android/mdpi.png" density="mdpi" /><icon src="resources/android/hdpi.png" density="hdpi" /><icon src="resources/android/xhdpi.png" density="xhdpi" /><icon src="resources/android/xxhdpi.png" density="xxhdpi" /><icon src="resources/android/xxxhdpi.png" density="xxxhdpi" /></platform>

and here is the sample code i am trying to check

Code

 BackgroundGeolocation.configure({        locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,        desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,        stationaryRadius: 50,        distanceFilter: 50,        notificationTitle: 'Background tracking',        notificationText: 'enabled',        debug: true,        interval: 10000,        fastestInterval: 5000,        activitiesInterval: 10000,      });

Output

Promise {}

Code

window.BackgroundGeolocation.checkStatus(function(status) {              console.log('[INFO] BackgroundGeolocation service is running', status.isRunning);              console.log('[INFO] BackgroundGeolocation services enabled',status.locationServicesEnabled);              console.log('[INFO] BackgroundGeolocation auth status: '+ status.authorization);            });

Output

undefined

i had tried this plugin every combination

<plugin name="cordova-background-geolocation-plugin"><variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" /><!-- <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="23+" /> --><!-- <variable name="ICON" value="@mipmap/ic_launcher" /><variable name="SMALL_ICON" value="@mipmap/ic_launcher" /> --><!-- <variable name="ACCOUNT_NAME" value="@string/app_name" /><variable name="ACCOUNT_LABEL" value="@string/app_name" /><variable name="ACCOUNT_TYPE" value="${PACKAGE_NAME}.account" /><variable name="CONTENT_AUTHORITY" value="${PACKAGE_NAME}" /> --><variable name="ALWAYS_USAGE_DESCRIPTION" value="App requires background tracking " /><variable name="MOTION_USAGE_DESCRIPTION" value="App requires motion detection" /> </plugin>

https://github.com/haylltd/cordova-background-geolocation-plugin

and i had also tried this plugin but voltbuilder made it deprecated

mauron85/cordova-plugin-background-geolocation

and i expect this code should give some output

Code

window.BackgroundGeolocation.checkStatus(function(status) {              console.log('[INFO] BackgroundGeolocation service is running', status.isRunning);              console.log('[INFO] BackgroundGeolocation services enabled',status.locationServicesEnabled);              console.log('[INFO] BackgroundGeolocation auth status: '+ status.authorization);            });

Viewing all articles
Browse latest Browse all 12111

Trending Articles