-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
79 lines (69 loc) · 2.42 KB
/
index.js
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
import messaging from '@react-native-firebase/messaging';
import React, {useEffect} from 'react';
import {Alert, AppRegistry, AppState, Platform} from 'react-native';
import RNCallKeep from 'react-native-callkeep';
import 'react-native-crypto';
import 'react-native-get-random-values';
import CallKeepHelper from 'src/helpers/CallkeepHelper';
import {NotifeClearBadge} from 'src/notifee';
import {getUUID} from 'src/push_video/payloads/helpers';
import MetaStorage from 'src/singletons/MetaStorage';
import 'text-encoding';
import App from './App';
import {name as appName} from './app.json';
import './shim';
/***************************************************/
/** Uncomment below commented code if video call **/
/** feature is enabled in the app **/
/***************************************************/
let isCallAccepted = false;
// this is supposed to be called wiz
// if (AppState.currentState !== 'active' && Platform.OS === 'android') {
// RNCallKeep.addEventListener('answerCall', async ({callUUID}) => {
// CallKeepHelper.backToForeground();
// CallKeepHelper.endAllCall();
// isCallAccepted = true;
// MetaStorage.instance.setBackgroundCallAccepted(false);
// });
// RNCallKeep.addEventListener('endCall', async ({callUUID}) => {
// CallKeepHelper.endAllCall();
// });
// }
function HeadlessCheck({isHeadless}) {
useEffect(() => {
NotifeClearBadge();
}, []);
if (isHeadless) {
// App has been launched in the background by iOS, ignore
return null;
}
return <App isCallAccepted={isCallAccepted} />;
}
// if (Platform.OS === 'android') {
// CallKeepHelper.setupCallKeep();
// RNCallKeep.setAvailable(true);
// }
// messaging().setBackgroundMessageHandler(async remoteMessage => {
// console.log('Message handled in the background!', remoteMessage);
// if (Platform.OS === 'android' && CallKeepHelper.isVideoCall(remoteMessage)) {
// const caller = CallKeepHelper.getCaller(remoteMessage);
// const addressTrimmed = CallKeepHelper.formatEthAddress(caller);
// const uuid = getUUID();
// RNCallKeep.displayIncomingCall(
// uuid,
// addressTrimmed,
// addressTrimmed,
// 'generic',
// true,
// );
// }
// });
if (isCallAccepted) {
AppRegistry.registerComponent(appName, () => HeadlessCheck);
} else {
AppRegistry.registerComponent(appName, () => HeadlessCheck);
}
AppRegistry.registerHeadlessTask(
'RNCallKeepBackgroundMessage',
() => bgCalling,
);