I created the app to get the Geolocation in the background, everything works fine when I am running the app in android 9, but when I run the app in android 10 and android 8 it crashes. I searched a lot but nothing found. Can any one tell me where I am doing wrong?
const config: BackgroundGeolocationConfig = {
locationProvider: 1,
desiredAccuracy: 0,
stationaryRadius: 20,
distanceFilter: 10,
interval: 100,
fastestInterval: 100,
activitiesInterval: 100,
url: API_URL+'save/location',
syncUrl: API_URL+'save/location',
notificationTitle: 'Tracking Location',
notificationText: 'GPS is tracking your location',
postTemplate: {
lat: '@latitude',
lon: '@longitude',
user: user.id
},
debug: false,
stopOnTerminate: false,
};
this.backgroundGeolocation.configure(config).then((location:BackgroundGeolocationResponse) => {
// alert(JSON.stringify(location));
});
this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {
// alert(JSON.stringify(location));
});
What are the versions you have and what the errors look like?
Also, if you have the version that I believe is 3.1.0 @mauron85 /cordova-plugin-background-geolocation if so, try: RAW_PROVIDER as locationProvider.
locationProvider: 2, // RAW_PROVIDER
INFO :
// Project: https://github.com/mauron85/cordova-plugin-background-geolocation // Definitions by: Mauron85 (@mauron85), Norbert Györög (@djereg) // Definitions: https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/BackgroundGeolocation.d.ts type Event = 'location' | 'stationary' | 'activity' | 'start' | 'stop' | 'error' | 'authorization' | 'foreground' | 'background' | 'abort_requested' | 'http_authorization'; type HeadlessTaskEventName = 'location' | 'stationary' | 'activity'; type iOSActivityType = 'AutomotiveNavigation' | 'OtherNavigation' | 'Fitness' | 'Other'; type NativeProvider = 'gps' | 'network' | 'passive' | 'fused'; type ActivityType = 'IN_VEHICLE' | 'ON_BICYCLE' | 'ON_FOOT' | 'RUNNING' | 'STILL' | 'TILTING' | 'UNKNOWN' | 'WALKING'; type LogLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR'; type LocationProvider = 0 | 1 | 2; type AuthorizationStatus = 0 | 1 | 2; type AccuracyLevel = 0 | 100 | 1000 | 10000 | number; type LocationErrorCode = 1 | 2 | 3; type ServiceMode = 0 | 1; export interface ConfigureOptions { /** * Set location provider * * Platform: all
* Platform: all * Available providers: * DISTANCE_FILTER_PROVIDER, * ACTIVITY_PROVIDER * RAW_PROVIDER * * @default DISTANCE_FILTER_PROVIDER * @example * { locationProvider: BackgroundGeolocation.RAW_PROVIDER } */ locationProvider?: LocationProvider; /** * Desired accuracy in meters. * * Platform: all * Provider: all * Possible values: * HIGH_ACCURACY, * MEDIUM_ACCURACY, * LOW_ACCURACY,
Also, make sure ionic native is up to date :
npm install @ionic-native/background-geolocation