This repository has been archived by the owner on May 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
index.js
91 lines (74 loc) · 2.61 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
80
81
82
83
84
85
86
87
88
89
90
91
'use strict';
import {
NativeModules,
Platform,
} from 'react-native';
import { listeners } from './actions'
const _RNCallKit = NativeModules.RNCallKit;
const _callkitEventHandlers = new Map();
export default class RNCallKit {
static addEventListener(type, handler) {
if (Platform.OS !== 'ios') return;
const listener = listeners[type](handler)
_callkitEventHandlers.set(handler, listener);
}
static removeEventListener(type, handler) {
if (Platform.OS !== 'ios') return;
var listener = _callkitEventHandlers.get(handler);
if (!listener) {
return;
}
listener.remove();
_callkitEventHandlers.delete(handler);
}
static setup(options) {
if (Platform.OS !== 'ios') return;
if (!options.appName) {
throw new Error('RNCallKit.setup: option "appName" is required');
}
if (typeof options.appName !== 'string') {
throw new Error('RNCallKit.setup: option "appName" should be of type "string"');
}
_RNCallKit.setup(options);
}
static displayIncomingCall(uuid, handle, handleType = 'number', hasVideo = false, localizedCallerName?: String) {
if (Platform.OS !== 'ios') return;
_RNCallKit.displayIncomingCall(uuid, handle, handleType, hasVideo, localizedCallerName);
}
static startCall(uuid, handle, handleType = 'number', hasVideo = false, contactIdentifier?: String) {
if (Platform.OS !== 'ios') return;
_RNCallKit.startCall(uuid, handle, handleType, hasVideo, contactIdentifier);
}
static reportConnectedOutgoingCallWithUUID(uuid) {
if (Platform.OS !== 'ios') return;
_RNCallKit.reportConnectedOutgoingCallWithUUID(uuid);
}
static endCall(uuid) {
if (Platform.OS !== 'ios') return;
_RNCallKit.endCall(uuid);
}
static endAllCalls() {
if (Platform.OS !== 'ios') return;
_RNCallKit.endAllCalls();
}
static setMutedCAll(uuid, muted) {
if (Platform.OS !== 'ios') return;
_RNCallKit.setMutedCall(uuid, muted);
}
static checkIfBusy() {
return Platform.OS === 'ios'
? _RNCallKit.checkIfBusy()
: Promise.reject('RNCallKit.checkIfBusy was called from unsupported OS');
};
static checkSpeaker() {
return Platform.OS === 'ios'
? _RNCallKit.checkSpeaker()
: Promise.reject('RNCallKit.checkSpeaker was called from unsupported OS');
}
/*
static setHeldCall(uuid, onHold) {
if (Platform.OS !== 'ios') return;
_RNCallKit.setHeldCall(uuid, onHold);
}
*/
}