react-native-callkeep
react-native-callkeep copied to clipboard
selfManaged mode not showing call in Call History
Bug report
-
[ ] I've checked the example to reproduce the issue.
-
Reproduced on:
-
[x] Android
-
[ ] iOS
Description
Android only: Call Keeps Works perfectly fine and I can see recent calls in phones Call History. However when I switch to selfManaged mode, present my UI (notification + foreground service) Call Keeps starts and ends as expected but calls are not visible in Call History on the phone, is this normal Call Keep behavior for android??
Register CallKeep
async initializeCallKeep(appName: string) {
try {
RNCallKeep.setup({
ios: {
appName: appName,
},
android: {
alertTitle: 'Permissions required',
alertDescription:
'This application needs to access your phone accounts',
cancelButton: 'Cancel',
okButton: 'ok',
additionalPermissions: [],
selfManaged: true,
foregroundService: {
channelId: 'acu_incoming_call',
channelName: 'Foreground service for my app',
notificationTitle: 'My app is running on background',
notificationIcon: 'Path to the resource icon of the notification',
},
},
});
RNCallKeep.setAvailable(true);
} catch (err: any) {
console.error('initializeCallKeep error:', err.message);
}
console.log('$$$ CallKeep Initialized $$$, ', appName);
// Add RNCallKit Events
RNCallKeep.addEventListener(
'didDisplayIncomingCall',
this.onIncomingCallDisplayed.bind(this)
);
RNCallKeep.addEventListener('answerCall', this.answerCall.bind(this));
RNCallKeep.addEventListener(
'didPerformDTMFAction',
this.onPerformDTMFAction.bind(this)
);
RNCallKeep.addEventListener(
'didReceiveStartCallAction',
this.onReceiveStartCallAction.bind(this)
);
RNCallKeep.addEventListener(
'didPerformSetMutedCallAction',
this.onPerformSetMutedCallAction.bind(this)
);
RNCallKeep.addEventListener('didActivateAudioSession', () => {
// you might want to do following things when receiving this event:
// - Start playing ringback if it is an outgoing call
this.answerCall;
});
RNCallKeep.addEventListener(
'showIncomingCallUi',
({ handle, callUUID, name }) => {
this.displayCustomIncomingUI(handle, callUUID, name);
console.log('********** Android showIncomingCallUi ********');
}
);
RNCallKeep.addEventListener('endCall', this.rejectCallCallKeep.bind(this));
// Android ONLY
DeviceEventEmitter.addListener('rejectedCallAndroid', (payload) => {
// End call action here
console.log('endCallAndroid REACT NATIVE REACT NATIVE', payload);
this.rejectCallCallKeep();
});
// Android ONLY
DeviceEventEmitter.addListener('answeredCallAndroid', (payload) => {
console.log('answerCallAndroid REACT NATIVE REACT NATIVE', payload);
this.answerCall();
});
}
Answer call
answerCall() {
this.setState({ callType: 'client' });
if (!this.state.callAnswered) {
this.answer();
this.setState({ callAnswered: true });
this.terminateCallIfNotConnected();
}
RNCallKeep.setCurrentCallActive(<string>this.state.callUuid);
this.setState({ incomingUUI: false });
}
answer Call CallKeep
async answer(): Promise<void> {
if (this.state.call !== null && this.state.callState === 'incoming call') {
this.state.callOptions.constraints = { audio: true, video: true };
this.state.callOptions.receiveAudio = true;
this.state.callOptions.receiveVideo = true;
this.state.call.answer(this.state.callOptions);
this.getCallUuid();
RNCallKeep.answerIncomingCall(<string>this.state.callUuid);
console.log('CALL ANSWERED WITH CALLKEEP', this.state.callUuid);
}
}
display custom UI
incomingCallNotification(
'acu_incoming_call',
'Incoming call',
'channel used to display incoming call notification',
this.state.incomingCallClientId,
1986
);
RNCallKeep.displayIncomingCall(
<string>this.state.callUuid,
this.state.incomingCallClientId,
this.state.incomingCallClientId
);
onCallDisconnected
afterDisconnected(): void {
this.setState({ callAnswered: false });
this.endCallKeepCall(<string>this.state.callUuid); //TEST
console.log('*********8 DISCONNEDCTED FIRED UP ********');
}
Reject the call
rejectCallCallKeep() {
try {
RNCallKeep.rejectCall(<string>this.state.callUuid);
this.reject();
} catch (err: any) {
console.error('rejectCallCallKeep error:', err.message);
}
}
Steps to Reproduce
Versions
- Callkeep: 4.3.2
- React Native: 0.66.0
- iOS:
- Android: 8.1.0
- Phone model: Moto G5 Plus
Logs
Paste here
not getting the logs either