-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfirmPage.js
More file actions
55 lines (50 loc) · 1.49 KB
/
ConfirmPage.js
File metadata and controls
55 lines (50 loc) · 1.49 KB
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
55
import React from "react";
import { WebView } from "react-native-webview";
import { Context } from "./Context";
import { useContext } from "react";
import { useNavigation } from "@react-navigation/native";
const ConfirmPage = ({ route }) => {
const navigation = useNavigation();
const { setApproved } = useContext(Context);
const { requestToken } = route.params;
// useEffect(() => {
// console.log(requestToken);
// }, []);
const handleWebViewNavigation = (event) => {
// Extract the URL from the event
const { url } = event;
// Check if the URL matches the confirmation page
if (url.includes("authenticate")) {
//console.log("Got there");
// Perform actions based on user interaction
if (url.includes("allow")) {
//console.log("User approved");
setApproved(true);
navigation.navigate("LoginScreen");
// Handle the user's approval action
} else if (url.includes("deny")) {
//console.log("User denied");
setApproved(false);
navigation.navigate("LoginScreen");
// Handle the user's denial action
}
}
};
return (
<WebView
source={{
uri: ` https://www.themoviedb.org/authenticate/${requestToken}`,
}}
onLoad={() => {
// console.log("Loaded")
}}
onNavigationStateChange={handleWebViewNavigation}
style={{
width: "100%",
flex: 1,
alignSelf: "center",
}}
/>
);
};
export default ConfirmPage;