From 645abcaf09efe94a1d6c9baaf8d5eb99a8035a47 Mon Sep 17 00:00:00 2001 From: Emmanuel Quentin Date: Mon, 9 Sep 2019 14:30:01 -0400 Subject: [PATCH 1/2] Minor updates --- README.md | 7 +-- .../io/wazo/callkeep/RNCallKeepModule.java | 2 +- example/App.js | 24 +++++++- .../xcschemes/CallKeepDemo.xcscheme | 2 +- example/package.json | 2 +- example/yarn.lock | 6 +- index.d.ts | 59 ++++++++++++++----- index.js | 35 +++++------ ios/RNCallKeep/RNCallKeep.m | 1 + 9 files changed, 90 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 5e062ea1..eb3f3899 100644 --- a/README.md +++ b/README.md @@ -187,15 +187,14 @@ Sets the Android caller name and number Use this to update the Android display after an outgoing call has started ```js -RNCallKeep.updateDisplay(uuid, localizedCallerName, handle) +RNCallKeep.updateDisplay(uuid, displayName, handle) ``` - `uuid`: string - The `uuid` used for `startCall` or `displayIncomingCall` +- `displayName`: string (optional) + - Name of the caller to be displayed on the native UI - `handle`: string - Phone number of the caller -- `localizedCallerName`: string (optional) - - Name of the caller to be displayed on the native UI - ### endCall diff --git a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java index f25f5ca5..2d9acf8f 100644 --- a/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java +++ b/android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java @@ -91,7 +91,7 @@ public class RNCallKeepModule extends ReactContextBaseJavaModule { private static final String[] permissions = { Manifest.permission.READ_PHONE_STATE, Manifest.permission.CALL_PHONE, Manifest.permission.RECORD_AUDIO }; - private static final String TAG = "RNCallKeepModule"; + private static final String TAG = "RNCK:RNCallKeepModule"; private static TelecomManager telecomManager; private static TelephonyManager telephonyManager; private static Promise hasPhoneAccountPromise; diff --git a/example/App.js b/example/App.js index 3e6f516c..82feed7c 100644 --- a/example/App.js +++ b/example/App.js @@ -54,6 +54,8 @@ const format = uuid => uuid.split('-')[0]; const getRandomNumber = () => String(Math.floor(Math.random() * 100000)); +const isIOS = Platform.OS === 'ios'; + export default function App() { const [logText, setLog] = useState(''); const [heldCalls, setHeldCalls] = useState({}); // callKeep uuid: held @@ -182,6 +184,18 @@ export default function App() { setCallMuted(callUUID, muted); }; + const updateDisplay = (callUUID) => { + const number = calls[callUUID]; + // Workaround because Android doesn't display well displayName, se we have to switch ... + if (isIOS) { + RNCallKeep.updateDisplay(callUUID, 'New Name', number); + } else { + RNCallKeep.updateDisplay(callUUID, number, 'New Name'); + } + + log(`[updateDisplay: ${number}] ${format(callUUID)}`); + }; + useEffect(() => { RNCallKeep.addEventListener('answerCall', answerCall); RNCallKeep.addEventListener('didPerformDTMFAction', didPerformDTMFAction); @@ -200,7 +214,7 @@ export default function App() { } }, []); - if (Platform.OS === 'ios' && DeviceInfo.isEmulator()) { + if (isIOS && DeviceInfo.isEmulator()) { return CallKeep doesn't work on iOS emulator; } @@ -224,6 +238,14 @@ export default function App() { {heldCalls[callUUID] ? 'Unhold' : 'Hold'} {calls[callUUID]} + updateDisplay(callUUID)} + style={styles.button} + hitSlop={hitSlop} + > + Update display + + setOnMute(callUUID, !mutedCalls[callUUID])} style={styles.button} diff --git a/example/ios/CallKeepDemo.xcodeproj/xcshareddata/xcschemes/CallKeepDemo.xcscheme b/example/ios/CallKeepDemo.xcodeproj/xcshareddata/xcschemes/CallKeepDemo.xcscheme index 3d76d2fd..9ef63b43 100644 --- a/example/ios/CallKeepDemo.xcodeproj/xcshareddata/xcschemes/CallKeepDemo.xcscheme +++ b/example/ios/CallKeepDemo.xcodeproj/xcshareddata/xcschemes/CallKeepDemo.xcscheme @@ -1,6 +1,6 @@ { + + } + /** * @description setMutedCall method is available only on iOS. */ @@ -100,6 +135,10 @@ export default class RNCallKeep { } + static setOnHold(uuid: string, held: boolean) { + + } + /** * @descriptions sendDTMF is used to send DTMF tones to the PBX. */ @@ -107,16 +146,10 @@ export default class RNCallKeep { } - /** - * @description setMutedCall method is available only on iOS. - */ static checkIfBusy(): Promise { } - /** - * @description setMutedCall method is available only on iOS. - */ static checkSpeaker(): Promise { } @@ -128,16 +161,10 @@ export default class RNCallKeep { } - /** - * @description setAvailable method is available only on Android. - */ static setCurrentCallActive() { } - /** - * @description setAvailable method is available only on Android. - */ static backToForeground() { } diff --git a/index.js b/index.js index 58561295..4408a467 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ class RNCallKeep { if (!isIOS) { RNCallKeepModule.answerIncomingCall(uuid); } - } + }; startCall = (uuid, handle, contactIdentifier, handleType = 'number', hasVideo = false ) => { if (!isIOS) { @@ -83,9 +83,8 @@ class RNCallKeep { } }; - reportEndCallWithUUID = (uuid, reason) => { + reportEndCallWithUUID = (uuid, reason) => RNCallKeepModule.reportEndCallWithUUID(uuid, reason); - } /* * Android explicitly states we reject a call @@ -97,15 +96,11 @@ class RNCallKeep { } else { RNCallKeepModule.endCall(uuid); } - } - - endCall = (uuid) => { - RNCallKeepModule.endCall(uuid); }; - endAllCalls = () => { - RNCallKeepModule.endAllCalls(); - }; + endCall = (uuid) => RNCallKeepModule.endCall(uuid); + + endAllCalls = () => RNCallKeepModule.endAllCalls(); supportConnectionService = () => supportConnectionService; @@ -119,9 +114,7 @@ class RNCallKeep { RNCallKeepModule.setMutedCall(uuid, shouldMute); }; - sendDTMF = (uuid, key) => { - RNCallKeepModule.sendDTMF(uuid, key); - }; + sendDTMF = (uuid, key) => RNCallKeepModule.sendDTMF(uuid, key); checkIfBusy = () => isIOS @@ -150,18 +143,18 @@ class RNCallKeep { RNCallKeepModule.setCurrentCallActive(callUUID); }; - updateDisplay = (uuid, displayName, uri) => { - RNCallKeepModule.updateDisplay(uuid, displayName, uri) - } + updateDisplay = (uuid, displayName, handle) => RNCallKeepModule.updateDisplay(uuid, displayName, handle); - setOnHold = (uuid, shouldHold) => { - RNCallKeepModule.setOnHold(uuid, shouldHold); - } + setOnHold = (uuid, shouldHold) => RNCallKeepModule.setOnHold(uuid, shouldHold); - reportUpdatedCall = (uuid, localizedCallerName) => - isIOS + // @deprecated + reportUpdatedCall = (uuid, localizedCallerName) => { + console.warn('RNCallKeep.reportUpdatedCall is deprecarted, use RNCallKeep.updateDisplay instead'); + + return isIOS ? RNCallKeepModule.reportUpdatedCall(uuid, localizedCallerName) : Promise.reject('RNCallKeep.reportUpdatedCall was called from unsupported OS'); + }; _setupIOS = async (options) => new Promise((resolve, reject) => { if (!options.appName) { diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 33dadded..6f3bb837 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -500,6 +500,7 @@ - (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallActio } // Update call contact info +// @deprecated RCT_EXPORT_METHOD(reportUpdatedCall:(NSString *)uuidString contactIdentifier:(NSString *)contactIdentifier) { #ifdef DEBUG From 124f63c0dc407937296efb53f80079ebb6245152 Mon Sep 17 00:00:00 2001 From: Emmanuel Quentin Date: Mon, 9 Sep 2019 14:49:03 -0400 Subject: [PATCH 2/2] Add github issue template --- .github/ISSUE_TEMPLATE.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..b5d0f52d --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,27 @@ +# Bug report + +- [ ] I've checked the [example](https://github.com/react-native-webrtc/react-native-callkeep/tree/master/example) to reproduce the issue. + +- Reproduced on: + - [ ] Android + - [ ] iOS + +## Description + + +## Steps to Reproduce + + +## Versions + - Callkeep: + - React Native: + - iOS: + - Android: + - Phone model: + + +## Logs + +``` +Paste here +```