-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
100 lines (87 loc) · 3.1 KB
/
App.js
File metadata and controls
100 lines (87 loc) · 3.1 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import {
MD3LightTheme as DefaultTheme,
Provider as PaperProvider,
} from "react-native-paper";
import { Provider, useDispatch } from "react-redux";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { store } from "./store/store";
import { GlobalStyles } from "./constants/styles";
// import AppNavigator from "./screen/AppNavigator";
import AppNavigator from "./Apps/Korespondensi/AppNavigator";
import { Host } from "react-native-portalize";
import { StatusBar, View, Text, Button } from "react-native";
import { COLORS } from "./config/SuperAppps";
import { Platform } from "react-native";
import { useEffect, useState } from "react";
import { DeviceType, getDeviceTypeAsync } from "expo-device";
import { setDevice } from "./store/Apps";
import { LogLevel, OneSignal } from "react-native-onesignal";
import Constants from "expo-constants";
import { setDataNotif } from "./store/pushnotif";
import * as Updates from 'expo-updates';
// OneSignal.setAppId(Constants.manifest.extra.oneSignalAppId);
// // promptForPushNotificationsWithUserResponse will show the native iOS or Android notification permission prompt.
// // We recommend removing the following code and instead using an In-App Message to prompt for notification permission (See step 8)
// OneSignal.promptForPushNotificationsWithUserResponse();
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
OneSignal.initialize("cf6dc0fa-3c36-4f98-a9a3-c760a0efa027");
// Also need enable notifications to complete OneSignal setup
OneSignal.Notifications.requestPermission(true);
export default function App() {
// const dispatch = useDispatch();
const [updateChecking, setUpdateChecking] = useState(false);
useEffect(() => {
triggerUpdate();
}, []);
const triggerUpdate = async () => {
try {
const update = await Updates.checkForUpdateAsync();
if(update.isAvailable){
await Updates.fetchUpdateAsync();
await Updates.reloadAsync();
} else {
Alert.alert("No updates available");
}
} catch (error) {
console.log("error", error);
}
}
const theme = {
...DefaultTheme,
roundness: 2,
version: 3,
colors: {
...DefaultTheme.colors,
primary: GlobalStyles.colors.primary,
secondary: GlobalStyles.colors.secondary,
tertiary: GlobalStyles.colors.tertiery,
secondaryContainer: GlobalStyles.colors.browhite,
},
};
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;
return (
<>
<SafeAreaProvider>
<Host>
<PaperProvider theme={theme}>
<Provider store={store}>
{/* <Wrapper> */}
<Button
title="Check for Updates"
onPress={async () => {
setUpdateChecking(true);
await triggerUpdate();
setUpdateChecking(false);
}}
>
</Button>
<AppNavigator />
{/* </Wrapper> */}
</Provider>
</PaperProvider>
</Host>
</SafeAreaProvider>
</>
);
}