-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
83 lines (76 loc) · 2.86 KB
/
index.js
File metadata and controls
83 lines (76 loc) · 2.86 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
import 'react-native-gesture-handler';
import {AppRegistry, YellowBox, Platform, Text, TextInput} from 'react-native';
import App from './app/index';
import {name as appName} from './app.json';
import settings from './app/config/settings';
import messaging from '@react-native-firebase/messaging';
import {Observable} from './app/modules/_CommonModels/ViewModelBase';
import NavigationService from './app/utils/app/NavigationService';
import {gotoEndedResultScreenWithSimulationId} from './app/utils/app/PushNotification';
import {hideSimulationStatus} from './app/modules/Test/ViewModels/CheckActiveSimulation/CheckActiveSimulation';
import {routes} from './app/navigation/rootNavigation/navigation.constants';
import SimulationPolling from './app/modules/Test/CommonFunctions/SimulationPolling';
YellowBox.ignoreWarnings(['getNode()', '..']);
YellowBox.disableLogBox = true;
try {
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;
TextInput.defaultProps = TextInput.defaultProps || {};
TextInput.defaultProps.allowFontScaling = false;
} catch (e) {}
if (settings.debug.log === false) {
console.log = () => {};
}
if (settings.debug.warn === false) {
console.warn = () => {};
}
if (Platform.OS === 'android') {
messaging().setBackgroundMessageHandler(async notification_message => {
console.log(
'messaging().setBackgroundMessageHandler(async remoteMessage => {',
notification_message,
);
if (notification_message) {
await Observable.setReduxValue(
'notification_message',
notification_message,
);
}
});
} else {
messaging().onNotificationOpenedApp(async notification_message => {
console.log('messaging().onNotificationOpenedApp', notification_message);
if (
notification_message &&
notification_message.data &&
(notification_message.data.type === 'simulation_terminated' ||
notification_message.data.type === 'simulation_autoterminated')
) {
const activeRouteName = NavigationService.getActiveRouteName();
console.log('activeRouteName', activeRouteName);
if (activeRouteName !== routes.TEST_RESULT_DETAIL) {
await hideSimulationStatus();
await gotoEndedResultScreenWithSimulationId(
notification_message.data.simulation_id,
);
SimulationPolling.stop();
}
await Observable.setReduxValue('notification_message', '');
}
});
messaging()
.getInitialNotification()
.then(async remoteMessage => {
console.log('messaging().getInitialNotification().then', remoteMessage);
if (remoteMessage) {
await Observable.setReduxValue('notification_message', remoteMessage);
}
});
}
const HeadlessCheck = args => {
if (Platform.OS === 'ios' && args && args.isHeadless === true) {
return null;
}
return App;
};
AppRegistry.registerComponent(appName, HeadlessCheck);