feat: use Capacitor Geolocation to prompt and get native location on Android
This commit is contained in:
@@ -14,6 +14,7 @@ import { useNotification } from '@/hooks/useNotification';
|
||||
import { processImageModeration } from '../hooks/useImageModeration';
|
||||
import { useTranslation } from '../hooks/useTranslation';
|
||||
import { processAndResizeImage } from '../utils/imageProcessor';
|
||||
import { getDeviceLocation } from '../utils/geolocation';
|
||||
|
||||
interface LandingPageProps {
|
||||
onContinue?: () => void;
|
||||
@@ -215,23 +216,10 @@ export const LandingPage: React.FC<LandingPageProps> = ({
|
||||
// 2. Get current mobile/device GPS position of the user
|
||||
if (finalLat === null || finalLng === null) {
|
||||
try {
|
||||
const pos = await Promise.race([
|
||||
new Promise<GeolocationPosition | null>((resolve) => {
|
||||
if (!navigator.geolocation) {
|
||||
resolve(null);
|
||||
} else {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(p) => resolve(p),
|
||||
() => resolve(null),
|
||||
{ timeout: 4000, enableHighAccuracy: true }
|
||||
);
|
||||
}
|
||||
}),
|
||||
new Promise<null>((resolve) => setTimeout(() => resolve(null), 4500))
|
||||
]);
|
||||
if (pos && pos.coords) {
|
||||
finalLat = pos.coords.latitude;
|
||||
finalLng = pos.coords.longitude;
|
||||
const deviceLoc = await getDeviceLocation();
|
||||
if (deviceLoc) {
|
||||
finalLat = deviceLoc.latitude;
|
||||
finalLng = deviceLoc.longitude;
|
||||
console.log('[Upload Location] Priority 2: GPS coordinates found:', finalLat, finalLng);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user