-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
40 lines (36 loc) · 1.04 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import loadable from "@loadable/component";
import React from "react";
import "react-native-gesture-handler";
import * as TaskManager from "expo-task-manager";
import { LocationObject } from "expo-location";
import { getExpoPushTokenAsync } from "expo-notifications";
import baseURL from "./baseURL";
TaskManager.defineTask("BACKGROUND_LOCATION", async ({ data, error }) => {
if (error) {
// check `error.message` for more details.
return;
}
if (data) {
const locs = ((data as any).locations.slice() as LocationObject[]).sort(
(a, b) => b.timestamp - a.timestamp
);
await fetch(`${baseURL}/notifications/location`, {
method: "POST",
body: JSON.stringify({
latitude: locs[0].coords.latitude,
longitude: locs[0].coords.longitude,
token: (
await getExpoPushTokenAsync({
experienceId: "@sohcah/PaperZee",
})
).data,
}),
});
}
});
const AppBase = loadable(() => import("./AppBase"));
export default function App() {
return (
<AppBase />
);
}