Skip to content

Commit 90c433e

Browse files
authored
Merge pull request react-native-webrtc#2 from wazo-pbx/add_missing_methods
Add missing Android methods
2 parents 596d28d + 89aabb6 commit 90c433e

File tree

6 files changed

+72
-16
lines changed

6 files changed

+72
-16
lines changed

README.md

+42-8
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ RNCallKeep.setActive(true);
8484
```
8585

8686
- `active`: boolean
87-
- Tell whenever the app is ready or not
87+
- Tell whenever the app is ready or not
8888

8989
### displayIncomingCall
9090

@@ -95,11 +95,11 @@ RNCallKeep.displayIncomingCall(uuid, handle);
9595
````
9696

9797
- `uuid`: string
98-
- An `uuid` that should be stored and re-used for `stopCall`.
98+
- An `uuid` that should be stored and re-used for `stopCall`.
9999
- `handle`: string
100-
- Phone number of the caller
100+
- Phone number of the caller
101101
- `localizedCallerName`: string (optional, iOS only)
102-
- Name of the caller to be displayed on the native UI
102+
- Name of the caller to be displayed on the native UI
103103
- `handleType`: string (optional, iOS only)
104104
- `generic`
105105
- `number` (default)
@@ -119,9 +119,9 @@ RNCallKeep.startCall(uuid, number);
119119
```
120120

121121
- _uuid_: string
122-
- An `uuid` that should be stored and re-used for `stopCall`.
122+
- An `uuid` that should be stored and re-used for `stopCall`.
123123
- `handle`: string
124-
- Phone number of the callee
124+
- Phone number of the callee
125125
- `handleType`: string (optional)
126126
- `generic`
127127
- `number` (default)
@@ -139,7 +139,7 @@ RNCallKeep.endCall(uuid);
139139
```
140140

141141
- `uuid`: string
142-
- The `uuid` used for `startCall` or `displayIncomingCall`
142+
- The `uuid` used for `startCall` or `displayIncomingCall`
143143

144144

145145
### setMutedCall
@@ -152,7 +152,7 @@ RNCallKeep.setMutedCall(uuid, true);
152152
```
153153

154154
- `uuid`: string
155-
- uuid of the current call.
155+
- uuid of the current call.
156156
- `muted`: boolean
157157

158158
### checkIfBusy
@@ -173,6 +173,29 @@ _This feature is available only on iOs._
173173
RNCallKeep.checkSpeaker();
174174
```
175175

176+
### supportConnectionService (async)
177+
178+
Tells if `ConnectionService` is available on the device (returns a boolean).
179+
180+
_This feature is available only on Android._
181+
182+
```js
183+
RNCallKeep.supportConnectionService();
184+
```
185+
186+
### hasPhoneAccount (async)
187+
188+
Checks if the user has enabled the [phone account](https://developer.android.com/reference/android/telecom/PhoneAccount) for your application.
189+
A phone account must be enable to be able to display UI screen on incoming call and make outgoing calls from native Contact application.
190+
191+
Returns a promise of a boolean.
192+
193+
_This feature is available only on Android._
194+
195+
```js
196+
await RNCallKeep.hasPhoneAccount();
197+
```
198+
176199
## Events
177200

178201
### didReceiveStartCallAction
@@ -250,6 +273,17 @@ A call was muted by the system or the user:
250273
```js
251274
RNCallKeep.addEventListener('didPerformSetMutedCallAction', ({ muted }) => {
252275

276+
});
277+
278+
```
279+
### - didPerformDTMFAction
280+
_This feature is available only on Android for now._
281+
282+
Used type a number on his dialer
283+
284+
```js
285+
RNCallKeep.addEventListener('didPerformDTMFAction', ({ dtmf }) => {
286+
253287
});
254288
```
255289

actions.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,14 @@ const didDisplayIncomingCall = handler =>
4343
const didPerformSetMutedCallAction = handler =>
4444
eventEmitter.addListener(RNCallKeepDidPerformSetMutedCallAction, (data) => { handler(data.muted); });
4545

46-
const didPerformDTMFAction = handler =>
46+
const didPerformDTMFAction = handler => {
47+
// @TODO: handle DTMF on iOS
48+
if (isIOS) {
49+
return;
50+
}
51+
4752
eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, (data) => { handler(data.number); });
53+
};
4854

4955
export const listeners = {
5056
didReceiveStartCallAction,

docs/ios-installation.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,17 @@ You'll now have the Library included.
5656

5757
![iOS Other libraries](pictures/ios-other-libraries.png)
5858

59-
### 2. Allow voip background
59+
### 2. Add header search path
6060

61-
2.1. Open `Info.plist` file and add `voip` in `UIBackgroundModes`.
61+
2.1. Click on `Build Settings` tab, then search for `Header Search Paths`.
62+
63+
2.2. Add `$(SRCROOT)/../node_modules/react-native-callkeep/ios/RNCallKeep`.
64+
65+
![iOS Search Paths](pictures/ios-search-paths.png)
66+
67+
### 3. Allow voip background
68+
69+
3.1. Open `Info.plist` file and add `voip` in `UIBackgroundModes`.
6270

6371
![iOS info.plist](pictures/ios-info-plist.png)
6472

@@ -71,15 +79,15 @@ By editing this file with a text editor, your should see:
7179
</array>
7280
```
7381

74-
### 3. Updating AppDelegate.m
82+
### 4. Updating AppDelegate.m
7583

76-
3.1. Import Library:
84+
4.1. Import Library:
7785

7886
```diff
7987
+ #import "RNCallKeep.h"
8088
```
8189

82-
3.2. Handling User Activity.
90+
4.2. Handling User Activity.
8391

8492
This delegate will be called when the user tries to start a call from native Phone App.
8593

docs/pictures/ios-search-paths.png

670 KB
Loading

index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { listeners } from './actions'
44

55
const RNCallKeepModule = NativeModules.RNCallKeep;
66
const isIOS = Platform.OS === 'ios';
7-
const hasConnectionService = !isIOS && Platform.Version >= 23;
7+
const supportConnectionService = !isIOS && Platform.Version >= 23;
88

99
class RNCallKeep {
1010

@@ -69,6 +69,14 @@ class RNCallKeep {
6969
isIOS ? RNCallKeepModule.endAllCalls() : RNCallKeepModule.endCall();
7070
}
7171

72+
supportConnectionService() {
73+
return supportConnectionService;
74+
}
75+
76+
async hasPhoneAccount() {
77+
return isIOS ? true : await RNCallKeepModule.hasPhoneAccount();
78+
}
79+
7280
setMutedCAll(uuid, muted) {
7381
if (!isIOS) {
7482
// Can't mute on Android

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-callkeep",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "iOS 10 CallKit and Android ConnectionService Framework For React Native",
55
"main": "index.js",
66
"scripts": {},

0 commit comments

Comments
 (0)