This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
forked from react-native-webrtc/react-native-callkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.js
86 lines (74 loc) · 2.35 KB
/
actions.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
80
81
82
83
84
85
import {
NativeModules,
NativeEventEmitter,
} from 'react-native';
const _RNCallKit = NativeModules.RNCallKit;
const _RNCallKitEmitter = new NativeEventEmitter(_RNCallKit);
const RNCallKitDidReceiveStartCallAction = 'RNCallKitDidReceiveStartCallAction';
const RNCallKitPerformAnswerCallAction = 'RNCallKitPerformAnswerCallAction';
const RNCallKitPerformEndCallAction = 'RNCallKitPerformEndCallAction';
const RNCallKitDidActivateAudioSession = 'RNCallKitDidActivateAudioSession';
const RNCallKitDidDeactivateAudioSession = 'RNCallKitDidDeactivateAudioSession';
const RNCallKitDidDisplayIncomingCall = 'RNCallKitDidDisplayIncomingCall';
const RNCallKitDidPerformSetMutedCallAction = 'RNCallKitDidPerformSetMutedCallAction';
const RNCallKitPerformPlayDTMFCallAction = 'RNCallKitPerformPlayDTMFCallAction';
didReceiveStartCallAction = handler => {
const listener = _RNCallKitEmitter.addListener(
RNCallKitDidReceiveStartCallAction,
(data) => { handler(data);}
);
_RNCallKit._startCallActionEventListenerAdded();
return listener;
}
answerCall = handler => (
_RNCallKitEmitter.addListener(
RNCallKitPerformAnswerCallAction,
(data) => { handler(data);}
)
)
endCall = handler => (
_RNCallKitEmitter.addListener(
RNCallKitPerformEndCallAction,
(data) => { handler(data); }
)
)
didActivateAudioSession = handler => (
_RNCallKitEmitter.addListener(
RNCallKitDidActivateAudioSession,
() => { handler(); }
)
)
didDeactivateAudioSession = handler => (
_RNCallKitEmitter.addListener(
RNCallKitDidDeactivateAudioSession,
() => { handler(); }
)
)
didDisplayIncomingCall = handler => (
_RNCallKitEmitter.addListener(
RNCallKitDidDisplayIncomingCall,
(data) => { handler(data.error, data.callUUID); }
)
)
didPerformSetMutedCallAction = handler => (
_RNCallKitEmitter.addListener(
RNCallKitDidPerformSetMutedCallAction,
(data) => { handler(data); }
)
)
playDTMF = handler => (
_RNCallKitEmitter.addListener(
RNCallKitPerformPlayDTMFCallAction,
(data) => { handler(data); }
)
)
export const listeners = {
didReceiveStartCallAction,
answerCall,
endCall,
playDTMF,
didActivateAudioSession,
didDeactivateAudioSession,
didDisplayIncomingCall,
didPerformSetMutedCallAction,
};