-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
135 lines (117 loc) · 4.09 KB
/
Copy pathindex.js
File metadata and controls
135 lines (117 loc) · 4.09 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* @format
*/
import {AppRegistry, Platform, Vibration, Linking} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import messaging from '@react-native-firebase/messaging';
import store from './src/store';
import userSlice from './src/slices/user';
import {request, check, PERMISSIONS, RESULTS} from 'react-native-permissions';
import {NavigationContainer} from '@react-navigation/native';
import AsyncStorage from '@react-native-async-storage/async-storage';
// import PushNotification, { Importance } from 'react-native-push-notification';
// PushNotification.configure({
// onNotification: function (notification) {
// console.log("NOTIFICATION:", notification);
// },
// onRegistrationError: function(err) {
// console.error(err.message, err);
// },
// // popInitialNotification: true,
// // requestPermissions: true,
// });
// PushNotification.createChannel({
// channelId: 'dodream',
// channelName: 'tincle',
// },
// (created) => console.log('createChannel returned', created))
// const handleFcmMessage = () => {
// const unsubscribe = messaging().onMessage(async remoteMessage => {
// console.log('new messag arrived')
// dispatch(
// userSlice.actions.setNotis({
// notis:true,
// }),
// );
// });
// messaging().onNotificationOpenedApp(remoteMessage => {
// console.log('Noti caused app to open from gb state: ', remoteMessage.notification,);
// });
// }
// const requestUserPermissionForFCM = async () => {
// const authStatus = await messaging().requestPermission();
// const enabled = authStatus === messaging.AuthorizationStatus.AUTHORIZED || authStatus === messaging.AuthorizationStatus.PROVISIONAL;
// if (enabled) {
// const fcmToken = await messaging().getToken();
// setFcm(fcmToken);
// handleFcmMessage();
// } else {
// console.log('fcm auth fail')
// }
// }
// requestUserPermissionForFCM();
// const requestNotificationPermission = async () => {
// //todo: ios
// if (Platform.OS === 'android') {
// const result = await request(PERMISSIONS.ANDROID.POST_NOTIFICATIONS);
// return result;
// }
// };
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log('[index.js] Message handled in the background!', remoteMessage);
// onMessageReceived(remoteMessage);
});
// const onMessageReceived = message => {
// console.log('[index.js] onMessageReceived: ', message);
// // if (Platform.OS === 'ios') {
// // // const {link = null} = message?.data || {}; // <---- 1
// // const pushDeepLink = message?.data?.link;
// // //console.log('pushDeepLink : ', pushDeepLink);
// // pushDeepLink && Linking.openURL(pushDeepLink);
// // Vibration.vibrate([400]);
// // }
// };
//원래 주석 아님
// const checkNotificationPermission = async () => {
// const result = await check(PERMISSIONS.ANDROID.POST_NOTIFICATIONS);
// return result;
// };
// const requestPermission = async () => {
// const checkPermission = await checkNotificationPermission();
// if (checkPermission !== RESULTS.GRANTED) {
// const request = await requestNotificationPermission();
// if (request !== RESULTS.GRANTED) {
// // permission not granted
// }
// }
// };
// requestPermission();
// messaging().setBackgroundMessageHandler(async remoteMessage => {
// console.log('Message: ', remoteMessage)
// store.dispatch(userSlice.actions.setNotis({notis:true,}));
// });
// messaging().onMessage(async remoteMessage => {
// console.log('new messag arrived:', remoteMessage)
// dispatch(
// userSlice.actions.setNotis({
// notis:true,
// }),
// );
// });
// messaging().onNotificationOpenedApp(remoteMessage => {
// console.log('Noti caused app to open from gb state: ', remoteMessage.notification,);
// });
AsyncStorage.setItem('app_start', 'true');
function headlessCheck({isHeadless}) {
if (isHeadless) {
return null;
}
return (
<NavigationContainer>
<App />
</NavigationContainer>
);
}
// AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerComponent(appName, () => headlessCheck);