CurrentPositionAsync() take very very long time to resolve

Please provide the following:

  1. SDK Version: 48.0.16
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

expo-location: 15.1.1

On android, expo-location CurrentPositionAsync() take super long time to resolve!

Methods I have tried,

  1. Location.getCurrentPositionAsync() sometimes never responds or takes a very long time to respond · Issue #10756 · expo/expo · GitHub
  2. setting accuracy to balanced.

However, it still take very long time to resolve.

Anyone facing the same problem?

This is my Code

export const fetchGPSLocation = (current_location = false) => {
	return new Promise(async (resolve, reject) => {
		let location = null;
		let tries = 1;
		do {
			try {
				if (current_location || tries >= 2) {
					location = await Promise.race([
						sleeping(5000),
						getCurrentPositionAsync({
							accuracy: LocationAccuracy.Balanced,
						}),
					])
				} else {
					location = await Promise.race([
						sleeping(2500),
						getLastKnownPositionAsync({
							maxAge: 60 * 1000,
							requiredAccuracy: LocationAccuracy.Balanced,
						})
					])
				}

				if (location) {
					return resolve(location)
				}

				tries++;
			} catch {
				tries++;
				// console.log('error tries = ' + tries.toString(), new Date().toLocaleString())
			}
		} while (location == null && tries < 3)

		return reject(t('errors.gps-error', {tries}));
	})
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.