-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
40 lines (31 loc) · 1.12 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
import React, { useState } from 'react';
import {NavigationContainer} from '@react-navigation/native';
import MainNavigator from './src/navigation/MainNavigator';
import {createNativeStackNavigator} from '@react-navigation/native-stack'
import LoginPage from './src/pages/Login/LoginPage';
// FCM
import messaging from '@react-native-firebase/messaging';
import { Alert } from 'react-native';
// FCM
messaging().setBackgroundMessageHandler(async (remoteMessage)=> {
console.log('Message hangled in the background!', remoteMessage);
});
export default function App() {
const Stack = createNativeStackNavigator()
// FCM
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log('Message hangled in the background!', remoteMessage);
});
React.useEffect(()=>{
const unsubscribe = messaging().onMessage(async remoteMessage =>{
Alert.alert("약을 복용할 시간입니다!", remoteMessage.notification?.body); // JSON.stringify(remoteMessage)
});
return unsubscribe;
});
// FCM 끝
return (
<NavigationContainer>
<MainNavigator />
</NavigationContainer>
);
}