-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
56 lines (45 loc) · 1.29 KB
/
App.js
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
56
import 'react-native-gesture-handler';
import Main from './src/App';
import { UserProvider } from './src/context/UserContext';
import * as WebBrowser from "expo-web-browser"
import * as React from 'react';
import {Amplify} from 'aws-amplify';
import awsconfig from './src/aws-exports';
import { Linking } from 'react-native';
const isLocalhost = Boolean(__DEV__)
const [
localRedirectSignIn,
productionRedirectSignIn
] = awsconfig.oauth.redirectSignIn.split(",");
const [
localRedirectSignOut,
productionRedirectSignOut
] = awsconfig.oauth.redirectSignOut.split(",");
// console.log(productionRedirectSignIn,localRedirectSignIn)
async function urlOpener(url, redirectUrl) {
const { type, url: newUrl } = await WebBrowser.openAuthSessionAsync(
url,
redirectUrl
);
if (type === "success" && Platform.OS === "ios") {
WebBrowser.dismissBrowser();
return Linking.openURL(newUrl);
}
}
const updatedConfig = {
...awsconfig,
oauth: {
...awsconfig.oauth,
redirectSignIn: isLocalhost ? localRedirectSignIn : productionRedirectSignIn,
redirectSignOut: isLocalhost ? localRedirectSignOut : productionRedirectSignOut,
urlOpener,
},
}
Amplify.configure(updatedConfig)
export default function App() {
return (
<UserProvider>
<Main/>
</UserProvider>
);
}