From ecbc1f2260d0f7c1f7cf0d5267590542e95c9d39 Mon Sep 17 00:00:00 2001 From: Ren Juan Date: Mon, 30 Aug 2021 00:56:54 +0000 Subject: [PATCH] * --- Ejectable/BGEO.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Ejectable/BGEO.js diff --git a/Ejectable/BGEO.js b/Ejectable/BGEO.js new file mode 100644 index 00000000..1eeb4461 --- /dev/null +++ b/Ejectable/BGEO.js @@ -0,0 +1,61 @@ +import React from 'react'; +import { StyleSheet } from 'react-native'; +import { Pressable } from 'react-native'; +import { Text, View } from './components/Themed.tsx'; +import * as TaskManager from 'expo-task-manager'; +import * as Location from 'expo-location'; +import { Trips, setBgOps } from './GT2'; + +const LOCATION_TASK_NAME = 'background-location-task'; + + const requestPermissions = async () => { + + if (!locEnabled) { + + const { status } = await Location.requestBackgroundPermissionsAsync(); + if (status === 'granted') { + await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, { + accuracy: Location.Accuracy.Balanced, + }); + setBgOps(true); + } + else setBgOps(false); + + } + +}; + +export default function PermissionsButton() { + return( + + + {'Enable background operations'} + + ); +} + +TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => { + + if (error) { + // Error occurred - check `error.message` for more details. + console.log(error.message); + return; + } + if (data) { + const { locations } = data; + Trips.deltaLoc( locations ); + } + +}); + +const styles = StyleSheet.create({ + container: { + marginVertical: 20, + marginBottom: -30, + alignItems: 'center', + }, + button: { + fontSize: 10, + backgroundColor: 'lime', + }, +});