diff --git a/README.md b/README.md index c72e563c..243efce2 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ RNCallKeep.setActive(true); ``` - `active`: boolean - - Tell whenever the app is ready or not + - Tell whenever the app is ready or not ### displayIncomingCall @@ -95,11 +95,11 @@ RNCallKeep.displayIncomingCall(uuid, handle); ```` - `uuid`: string - - An `uuid` that should be stored and re-used for `stopCall`. + - An `uuid` that should be stored and re-used for `stopCall`. - `handle`: string - - Phone number of the caller + - Phone number of the caller - `localizedCallerName`: string (optional, iOS only) - - Name of the caller to be displayed on the native UI + - Name of the caller to be displayed on the native UI - `handleType`: string (optional, iOS only) - `generic` - `number` (default) @@ -119,9 +119,9 @@ RNCallKeep.startCall(uuid, number); ``` - _uuid_: string - - An `uuid` that should be stored and re-used for `stopCall`. + - An `uuid` that should be stored and re-used for `stopCall`. - `handle`: string - - Phone number of the callee + - Phone number of the callee - `handleType`: string (optional) - `generic` - `number` (default) @@ -139,7 +139,7 @@ RNCallKeep.endCall(uuid); ``` - `uuid`: string - - The `uuid` used for `startCall` or `displayIncomingCall` + - The `uuid` used for `startCall` or `displayIncomingCall` ### setMutedCall @@ -152,7 +152,7 @@ RNCallKeep.setMutedCall(uuid, true); ``` - `uuid`: string - - uuid of the current call. + - uuid of the current call. - `muted`: boolean ### checkIfBusy @@ -173,6 +173,29 @@ _This feature is available only on iOs._ RNCallKeep.checkSpeaker(); ``` +### supportConnectionService (async) + +Tells if `ConnectionService` is available on the device (returns a boolean). + +_This feature is available only on Android._ + +```js +RNCallKeep.supportConnectionService(); +``` + +### hasPhoneAccount (async) + +Checks if the user has enabled the [phone account](https://developer.android.com/reference/android/telecom/PhoneAccount) for your application. +A phone account must be enable to be able to display UI screen on incoming call and make outgoing calls from native Contact application. + +Returns a promise of a boolean. + +_This feature is available only on Android._ + +```js +await RNCallKeep.hasPhoneAccount(); +``` + ## Events ### didReceiveStartCallAction @@ -250,6 +273,17 @@ A call was muted by the system or the user: ```js RNCallKeep.addEventListener('didPerformSetMutedCallAction', ({ muted }) => { +}); + +``` +### - didPerformDTMFAction +_This feature is available only on Android for now._ + +Used type a number on his dialer + +```js +RNCallKeep.addEventListener('didPerformDTMFAction', ({ dtmf }) => { + }); ``` diff --git a/actions.js b/actions.js index f545c8dc..2b7116e0 100644 --- a/actions.js +++ b/actions.js @@ -43,8 +43,14 @@ const didDisplayIncomingCall = handler => const didPerformSetMutedCallAction = handler => eventEmitter.addListener(RNCallKeepDidPerformSetMutedCallAction, (data) => { handler(data.muted); }); -const didPerformDTMFAction = handler => +const didPerformDTMFAction = handler => { + // @TODO: handle DTMF on iOS + if (isIOS) { + return; + } + eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, (data) => { handler(data.number); }); +}; export const listeners = { didReceiveStartCallAction, diff --git a/docs/ios-installation.md b/docs/ios-installation.md index 27805623..547e5174 100644 --- a/docs/ios-installation.md +++ b/docs/ios-installation.md @@ -56,9 +56,17 @@ You'll now have the Library included. ![iOS Other libraries](pictures/ios-other-libraries.png) -### 2. Allow voip background +### 2. Add header search path -2.1. Open `Info.plist` file and add `voip` in `UIBackgroundModes`. +2.1. Click on `Build Settings` tab, then search for `Header Search Paths`. + +2.2. Add `$(SRCROOT)/../node_modules/react-native-callkeep/ios/RNCallKeep`. + +![iOS Search Paths](pictures/ios-search-paths.png) + +### 3. Allow voip background + +3.1. Open `Info.plist` file and add `voip` in `UIBackgroundModes`. ![iOS info.plist](pictures/ios-info-plist.png) @@ -71,15 +79,15 @@ By editing this file with a text editor, your should see: ``` -### 3. Updating AppDelegate.m +### 4. Updating AppDelegate.m -3.1. Import Library: +4.1. Import Library: ```diff + #import "RNCallKeep.h" ``` -3.2. Handling User Activity. +4.2. Handling User Activity. This delegate will be called when the user tries to start a call from native Phone App. diff --git a/docs/pictures/ios-search-paths.png b/docs/pictures/ios-search-paths.png new file mode 100644 index 00000000..a602e94d Binary files /dev/null and b/docs/pictures/ios-search-paths.png differ diff --git a/index.js b/index.js index e3247054..3db01d29 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ import { listeners } from './actions' const RNCallKeepModule = NativeModules.RNCallKeep; const isIOS = Platform.OS === 'ios'; -const hasConnectionService = !isIOS && Platform.Version >= 23; +const supportConnectionService = !isIOS && Platform.Version >= 23; class RNCallKeep { @@ -69,6 +69,14 @@ class RNCallKeep { isIOS ? RNCallKeepModule.endAllCalls() : RNCallKeepModule.endCall(); } + supportConnectionService() { + return supportConnectionService; + } + + async hasPhoneAccount() { + return isIOS ? true : await RNCallKeepModule.hasPhoneAccount(); + } + setMutedCAll(uuid, muted) { if (!isIOS) { // Can't mute on Android diff --git a/package.json b/package.json index b15afb04..9603c9ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-callkeep", - "version": "0.0.1", + "version": "0.0.2", "description": "iOS 10 CallKit and Android ConnectionService Framework For React Native", "main": "index.js", "scripts": {},