-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
58 lines (53 loc) · 1.75 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
55
56
57
58
import React, { useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { NativeBaseProvider } from 'native-base';
import { composeWithDevTools } from 'redux-devtools-extension';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import { rootReducer } from './src/reducers';
import { AppNavigator } from './src/navigation/AppNavigator';
import RNPermissions, {
PERMISSIONS,
} from 'react-native-permissions';
import messaging from '@react-native-firebase/messaging';
import { Alert } from 'react-native';
const store = createStore(
rootReducer,
composeWithDevTools(applyMiddleware(ReduxThunk))
);
const App = () => {
useEffect(() => {
async function requestUserPermission() {
const authStatus = await messaging().requestPermission();
const enabled =
authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
authStatus === messaging.AuthorizationStatus.PROVISIONAL;
if (enabled) {
console.log('Authorization status:', authStatus);
}
RNPermissions.request(PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE)
}
requestUserPermission();
const unsubscribe = messaging().onMessage(async remoteMessage => {
if (remoteMessage && remoteMessage.notification) {
Alert.alert(`${remoteMessage.notification.title}`, remoteMessage.notification.body, [
{
text: '좋아요!',
},
])
}
});
return unsubscribe;
}, []);
return (
<Provider store={store}>
<NativeBaseProvider>
<NavigationContainer>
<AppNavigator />
</NavigationContainer>
</NativeBaseProvider>
</Provider>
);
};
export default App;