My application is about making timely validation on student attendance.
First, I want to check whether the student is in the right location, I have set a timer by which if student is not in their location for 20s, then the system will notify them. If they are in the right collection, proceed to timely validation:
const timer = BackgroundTimer.setInterval(() => {
time++;
if(!notFound){
RNEP.proximityObserver.stopObservingZones();
BackgroundTimer.clearInterval(timer);
dispatch({type: RIGHT_LOCATION});
startProximityObserver();
}
if(time > 20){
RNEP.proximityObserver.stopObservingZones();
BackgroundTimer.clearInterval(timer);
dispatch({type: WRONG_LOCATION});
}
}, 1000);
The timely validation is to constantly check if the student is in that place or not:
startProximityObserver(){
zone.onEnterAction = () => {
const timer = BackgroundTimer.setInterval(() => {
//Wont execute on second call
}, 1000);
};
zone.onExitAction = () => {
dispatch({
type: EXIT_CLASS,
payload: { inClass: false }
});
};
RNEP.proximityObserver.startObservingZones([zone]);
}
The startObservingZones does not executed on the second call. Is it because I call the stopObservingZones event or because of the timer? Thank you