Skip to content

Minor updates #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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
```
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 23 additions & 1 deletion example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylekurz @bhuangy @danjenkins on Android I have to switch displayName and handle arguments to have them displayed correctly (unless the displayName is not taken in account).
Weirdly the Android code seems to be OK ...

Have you this issue too ? I can reproduce with the example on a Pixel 1 (Android 9).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use the updateDisplay api yet so I can't comment :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather update the underlying modules so they can both have the arguments in the same order, instead of doing a platform check here, personally...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too but my point is that the arguments on the Android side are good. I don't want to call setAddress with the displayName and setCallerDisplayName with the handle ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really make sense. We should be figuring out what's going on underneath instead of providing a strange example.

For our app, we have the following scenarios:

  1. Incoming call - Always displays name properly
  2. Outgoing call started from our app - Always displays name properly
  3. Outgoing call started from native dialer - Only displays the number

Does this match your experience? I think if you switch the items, you'll end up with a call log that has the right name, but the URI will be useless if someone tries to call it back.

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);
Expand All @@ -200,7 +214,7 @@ export default function App() {
}
}, []);

if (Platform.OS === 'ios' && DeviceInfo.isEmulator()) {
if (isIOS && DeviceInfo.isEmulator()) {
return <Text style={styles.container}>CallKeep doesn't work on iOS emulator</Text>;
}

Expand All @@ -224,6 +238,14 @@ export default function App() {
<Text>{heldCalls[callUUID] ? 'Unhold' : 'Hold'} {calls[callUUID]}</Text>
</TouchableOpacity>

<TouchableOpacity
onPress={() => updateDisplay(callUUID)}
style={styles.button}
hitSlop={hitSlop}
>
<Text>Update display</Text>
</TouchableOpacity>

<TouchableOpacity
onPress={() => setOnMute(callUUID, !mutedCalls[callUUID])}
style={styles.button}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1030"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react-dom": "^16.8.6",
"react-native": "0.59.8",
"react-native-background-timer": "^2.1.1",
"react-native-callkeep": "https://github.com/react-native-webrtc/react-native-callkeep",
"react-native-callkeep": "https://github.com/react-native-webrtc/react-native-callkeep#fix_outgoing_call_ios",
"react-native-device-info": "^2.3.2",
"react-native-gesture-handler": "~1.3.0",
"react-native-reanimated": "~1.1.0",
Expand Down
6 changes: 3 additions & 3 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4132,9 +4132,9 @@ react-native-branch@~3.0.1:
resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-3.0.1.tgz#5b07b61cbd290168cd3c3662e017ebe0f356d2ca"
integrity sha512-vbcYxPZlpF5f39GAEUF8kuGQqCNeD3E6zEdvtOq8oCGZunHXlWlKgAS6dgBKCvsHvXgHuMtpvs39VgOp8DaKig==

"react-native-callkeep@https://github.com/react-native-webrtc/react-native-callkeep":
version "3.0.0"
resolved "https://github.com/react-native-webrtc/react-native-callkeep#46b9a488f737a002d73327847a8d8190f171754a"
"react-native-callkeep@https://github.com/react-native-webrtc/react-native-callkeep#fix_outgoing_call_ios":
version "3.0.1"
resolved "https://github.com/react-native-webrtc/react-native-callkeep#22a3f2d9f8ede5e83f88d9a16c3786efe249ce1f"

react-native-device-info@^2.3.2:
version "2.3.2"
Expand Down
59 changes: 43 additions & 16 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ export type Events =
'answerCall' |
'endCall' |
'didActivateAudioSession' |
'didDeactivateAudioSession' |
'didDisplayIncomingCall' |
'didToggleHoldCallAction' |
'didPerformDTMFAction' |
'didResetProvider' |
'didPerformSetMutedCallAction';

type HandleType = 'generic' | 'number' | 'email';
Expand All @@ -12,13 +16,18 @@ interface IOptions {
ios: {
appName: string,
imageName?: string,
supportsVideo: false,
maximumCallGroups: '1',
maximumCallsPerCallGroup: '1'
ringtoneSound?: string,
},
android: {
alertTitle: string,
alertDescription: string,
cancelButton: string,
okButton: string,
imageName?: string,
additionalPermissions: string[],
},
}

Expand All @@ -41,6 +50,10 @@ export default class RNCallKeep {

}

static hasDefaultPhoneAccount(): boolean {

}

static displayIncomingCall(
uuid: string,
handle: string,
Expand All @@ -51,15 +64,19 @@ export default class RNCallKeep {

}

/**
* @description startCall method is available only on iOS.
*/
static startCall(
uuid: string,
handle: string,
contactIdentifier?: string,
handleType?: HandleType,
hasVideo?: boolean,
contactIdentifier?: string,
) {

}
static updateDisplay(
uuid: string,
displayName: string,
handle: string,
) {

}
Expand All @@ -71,6 +88,20 @@ export default class RNCallKeep {

}

/**
* @description reportConnectedOutgoingCallWithUUID method is available only on iOS.
*/
static reportConnectingOutgoingCallWithUUID(uuid: string): void {

}
static reportEndCallWithUUID(uuid: string, reason: number): void {

}

static rejectCall(uuid: string) {

}

static endCall(uuid: string) {

}
Expand All @@ -93,30 +124,32 @@ export default class RNCallKeep {

}

static async hasOutgoingCall(): Promise<boolean> {

}

/**
* @description setMutedCall method is available only on iOS.
*/
static setMutedCall(uuid: string, muted: boolean) {

}

static setOnHold(uuid: string, held: boolean) {

}

/**
* @descriptions sendDTMF is used to send DTMF tones to the PBX.
*/
static sendDTMF(uuid: string, key: string) {

}

/**
* @description setMutedCall method is available only on iOS.
*/
static checkIfBusy(): Promise<boolean> {

}

/**
* @description setMutedCall method is available only on iOS.
*/
static checkSpeaker(): Promise<boolean> {

}
Expand All @@ -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() {

}
Expand Down
35 changes: 14 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class RNCallKeep {
if (!isIOS) {
RNCallKeepModule.answerIncomingCall(uuid);
}
}
};

startCall = (uuid, handle, contactIdentifier, handleType = 'number', hasVideo = false ) => {
if (!isIOS) {
Expand All @@ -83,9 +83,8 @@ class RNCallKeep {
}
};

reportEndCallWithUUID = (uuid, reason) => {
reportEndCallWithUUID = (uuid, reason) =>
RNCallKeepModule.reportEndCallWithUUID(uuid, reason);
}

/*
* Android explicitly states we reject a call
Expand All @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down