-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·70 lines (58 loc) · 1.81 KB
/
index.js
File metadata and controls
executable file
·70 lines (58 loc) · 1.81 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
/** @format */
import { AppRegistry, Platform, NativeModules } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import messaging from '@react-native-firebase/messaging';
import RNCallKeep from 'react-native-callkeep';
const { LaunchManager } = NativeModules;
const options = {
ios: {
appName: 'Instachatty',
},
android: {
alertTitle: 'Permissions required',
alertDescription: 'This application needs to access your phone accounts',
cancelButton: 'Cancel',
okButton: 'ok',
},
};
RNCallKeep.setup(options);
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log('xxxxxxx ' + JSON.stringify(remoteMessage));
presentIncomingCall(remoteMessage);
});
presentIncomingCall = async (remoteMessage) => {
if (Platform.OS != 'android') {
return;
}
// const options = {
// ios: {
// appName: 'Instachatty',
// },
// android: {
// alertTitle: 'Permissions required',
// alertDescription: 'This application needs to access your phone accounts',
// cancelButton: 'Cancel',
// okButton: 'ok',
// },
// };
try {
// RNCallKeep.setup(options);
RNCallKeep.setAvailable(true);
RNCallKeep.addEventListener('answerCall', (body) =>
onAnswerCallAction(body, remoteMessage.data),
);
const { callID, callerName } = remoteMessage.data;
console.log(callerName);
RNCallKeep.displayIncomingCall(callID, callerName, callerName);
} catch (error) {
console.log(error);
}
};
onAnswerCallAction = async (body, data) => {
await RNCallKeep.removeEventListener('endCall');
console.log('onAnswerCallAction ' + body.callUUID);
RNCallKeep.rejectCall(body.callUUID);
LaunchManager.openAppWithData(JSON.stringify(data));
};
AppRegistry.registerComponent(appName, () => App);