Saltar al contenido

Primeros pasos

GitHub
Ventana de la terminal
bun add @capgo/capacitor-mock-location-detector
bunx cap sync
import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.getCapabilities();
console.log(result);
import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.analyze();
console.log(result);
import { MockLocationDetector } from '@capgo/capacitor-mock-location-detector';
const result = await MockLocationDetector.runCheck({ check: 'system_mock_flag' });
console.log(result);
  • Listeners: elimina los handles al desmontar pantallas.
  • Native sync: ejecuta bunx cap sync tras actualizar el plugin.
  • Fuente de verdad: confía en src/definitions.ts en el repo de GitHub.
const result = await MockLocationDetector.analyze({
requestLocationSample: true,
minDetectedChecks: 1,
});
if (result.isSimulated) {
console.warn('Possible GPS spoofing detected', result.riskScore, result.checks);
}
const mockFlag = await MockLocationDetector.runCheck({
check: 'system_mock_flag',
});
await MockLocationDetector.addListener('locationIntegrityChanged', (event) => {
console.log('Integrity changed', event.confidence, event.checks);
});
await MockLocationDetector.startMonitoring({ intervalMs: 30000 });

Las apps no pueden desactivar el modo desarrollador o la ubicación simulada automáticamente. Abre los ajustes:

await MockLocationDetector.openDeveloperSettings();

Esta página sigue la guía del plugin src/definitions.ts. Ejecuta docgen upstream de nuevo cuando cambie el API público.