Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin API Call Not Following locationTemplate #2231

Closed
dougschurman opened this issue Dec 17, 2024 · 1 comment
Closed

Plugin API Call Not Following locationTemplate #2231

dougschurman opened this issue Dec 17, 2024 · 1 comment

Comments

@dougschurman
Copy link

dougschurman commented Dec 17, 2024

Your Environment

  • Plugin version: 4.17.4
  • Platform: iOS
  • OS version: 18.1.1
  • Device manufacturer / model: iPhone 12
  • React Native version (react-native -v): 74
  • Plugin config
BackgroundGeolocation.ready({
			// Geolocation Config
			desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
			logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
			stopOnTerminate: false, // Allow the background-service to continue tracking when user closes the app.
			enableHeadless: true, // Allow android tracking when app is terminated stopOnTerminate must be false
			startOnBoot: true, // Auto start tracking when device is powered-up.
			preventSuspend: true,
			elasticityMultiplier: 10,
			distanceFilter: 200,
			stopTimeout: 15, // change state to stationary after 15 minutes of no movement
			heartbeatInterval: 1 * 60, // Every 1 minutes trigger iOS to wake up and get location
			url: `${DRIVER_API_BASE_URL}locations/location`,
			httpRootProperty: '.', // specify data as root of json
			locationTemplate: '{"latitude":<%= latitude %>,"longitude":<%= longitude %>}',
			extras: {
				accuracyInFeet: 5280,
				osVersion: env.appVersion || null,
				fromNotification: false,
			},
			notification: {
				title: 'Driver Mobile',
				text: 'Currently tracking Shipment progress.',
			},
		}).then(() => {
			console.log('- BackgroundGeolocation is configured and ready');
		});

Expected Behavior

When setting the locationTemplate config, it should create the JSON request with the specified names and inserted variables.

Actual Behavior

The resulting JSON request to the API has the default named JSON property names.

Context

I am trying to send a JSON body to my API that looks like

{longitude: -86.15916036467566, latitude: 39.7706582761631, fromNotification: false, osVersion: "2.10.0"}

But instead, with the given config, it ends up looking like

{lng: -86.15916036467566, lat: 39.7706582761631, fromNotification: false, osVersion: "2.10.0"}

Debug logs

Logs

image

@dougschurman
Copy link
Author

Had to redownload the Expo dev build in order for the changes to apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant