Closed thur-c closed 3 weeks ago
That’s correct.
This is explained in the wiki “Debugging”.
the plug-in doesn’t detect movement with location changes. It detects movement via Motion API and the Motion api doesn’t operate in the simulator.
In the emulator, you must manually call .changePace(true) to tell the plug-in to turn on location-services and begin receiving location updates.
the best way to test this plug-in is with a real device with real movement.
Btw, don’t wait until .start() resolves to add listeners.
add them before. Adding listeners is like wiring up speakers to a stereo. You don’t wait until you turn your stereo on to hook up your speakers (you might miss the start of the song). You do it once (when your app boots).
adding listeners (eg .onLocation) does nothing more than add a callback function to an Array. It is a completely harmless and inexpensive action.
Can't get the current position while moving
interface LocationContextType { currentLocation: Location | undefined; }
interface LocationContextProps { children: React.ReactNode; }
export const LocationContext = createContext({} as LocationContextType);
export function LocationContextProvider({ children }: LocationContextProps) { const {uid, token} = useContext(UserContext); const [enabled, setEnabled] = useState(false); const [currentLocation, setCurrentLocation] = useState<Location | undefined>();
}