forked from react-native-webrtc/react-native-callkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.js
68 lines (58 loc) · 1.84 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
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 RNCallKitDidDisplayIncomingCall = 'RNCallKitDidDisplayIncomingCall';
const RNCallKitDidPerformSetMutedCallAction = 'RNCallKitDidPerformSetMutedCallAction';
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(); }
)
)
didDisplayIncomingCall = handler => (
_RNCallKitEmitter.addListener(
RNCallKitDidDisplayIncomingCall,
(data) => { handler(data.error); }
)
)
didPerformSetMutedCallAction = handler => (
_RNCallKitEmitter.addListener(
RNCallKitDidPerformSetMutedCallAction,
(data) => { handler(data.muted); }
)
)
export const listeners = {
didReceiveStartCallAction,
answerCall,
endCall,
didActivateAudioSession,
didDisplayIncomingCall,
didPerformSetMutedCallAction,
};