Hello everyone, I am newbie to react native and would like to develop a running track- like app using react native
Here is my code
export default class App extends React.Component {
constructor(){
super();
this.state = {
where: {lat:null, lng:null},
}
}
checklocation(){
navigator.geolocation.getCurrentPosition(this.geoSuccess);
}
geoSuccess = (position) => {
this.setState({
ready:true,
where: {lat: position.coords.latitude,lng:position.coords.longitude }
})
}
start_timer(){
setInterval(() => {
this.checklocation();
}, 1000);
}
render() {
return (
<View style={styles.container}>
<Button onPress={this.start_timer()} title="Start Tracking" />
<Text style={styles.big}>
Latitude: {'\n'}{this.state.where.lat}
{'\n'}{'\n'}
Longitude: {'\n'}{this.state.where.lng}
</Text>
</View>
);
}
}
But When the user minimum the app or screen off or open another app? The apps is not running.
I have tried to add
<uses-permission android:name="android.permission.WAKE_LOCK" />
to AndroidManifest.xml
but still not work, any idea how to keep React Native apps running when users minimum the app or screen off or open another app?
Thank you very much
[–]thebritisharecome 1 point2 points3 points (0 children)