-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
54 lines (47 loc) · 1.62 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React, { useEffect } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { StatusBar, Platform } from "react-native";
import * as Notifications from "expo-notifications";
import * as Linking from "expo-linking";
import Routes from "./src/routes/resolver";
import { AuthProvider } from "./src/contexts/auth";
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});
const App: React.FC = () => {
useEffect(() => {
Notifications.addNotificationReceivedListener(_handleNotification);
Notifications.addNotificationResponseReceivedListener(_handleNotificationResponse);
}, []);
function _handleNotification(notification) {
// console.log(notification.request.content.data.body);
}
function _handleNotificationResponse(response) {
console.log("Aqui")
// console.log(response.notification.request.content.data.x)
// return;
const x = response.notification.request.content.data.x;
const y = response.notification.request.content.data.y;
// console.log(x, y);
if (Platform.OS === "android") {
Linking.openURL(`http://maps.google.com/maps?daddr=${x},${y}`).catch((err) =>
console.error("An error occurred", err)
);
} else {
Linking.openURL(`maps://maps.apple.com/?q=${x},${y}`);
}
}
return (
<NavigationContainer>
<AuthProvider>
<StatusBar barStyle="dark-content" backgroundColor="transparent" translucent />
<Routes />
</AuthProvider>
</NavigationContainer>
);
};
export default App;