Good day,
I am coding a compass application in react and have some problems.
I am working with a DeviceOrientationEvent, if i add an EventListener it orientates to the device heading, not to the absolute earth heading.
My idea is, to display a calibration button, the user has to orientate his phone to north (deviceheading === absolute earth heading) and then press the button.
Here a code example:
calibrationButtonOnClick() //Method which is executed when pressing the calibration button
{
orientationHandler = await Motion.addListener("orientation", (event:any) => {orientationChange(event)});
//The orientationHandler object i want to store permanent.
}
If the button get pressed, i set the orientation event listener and get a DeviceOrientationEvent which points to north.
My problem: If i restart the application i have to calibrate the app new.
My idea: Calibrate it once and than store the "DeviceOrientationEvent" instance permanently. After restarting i can load and use it.
Have you some idea how i can store an object instance?
I´ll publish the application as android app
Thanks for help!
One option is to make use of local storage to store the data.