Skip to content

Commit

Permalink
bug/MOB-5329: iOS: No outbound call ringing sound when placing a call…
Browse files Browse the repository at this point in the history
… from native call history on iPhone (CS3)
  • Loading branch information
rcidt committed Jan 18, 2024
1 parent b9a8c4b commit 2d9a059
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 20 deletions.
5 changes: 5 additions & 0 deletions actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const RNCallKeepDidDeactivateAudioSession = 'RNCallKeepDidDeactivateAudioSession
const RNCallKeepDidDisplayIncomingCall = 'RNCallKeepDidDisplayIncomingCall';
const RNCallKeepDidPerformSetMutedCallAction = 'RNCallKeepDidPerformSetMutedCallAction';
const RNCallKeepDidToggleHoldAction = 'RNCallKeepDidToggleHoldAction';
const RNCallKeepPerformGroupCallAction = 'RNCallKeepPerformGroupCallAction';
const RNCallKeepDidPerformDTMFAction = 'RNCallKeepDidPerformDTMFAction';
const RNCallKeepProviderReset = 'RNCallKeepProviderReset';
const RNCallKeepCheckReachability = 'RNCallKeepCheckReachability';
Expand Down Expand Up @@ -63,6 +64,9 @@ const didPerformSetMutedCallAction = handler =>
const didToggleHoldCallAction = handler =>
eventEmitter.addListener(RNCallKeepDidToggleHoldAction, handler);

const performGroupCallAction = handler =>
eventEmitter.addListener(RNCallKeepPerformGroupCallAction, handler);

const didPerformDTMFAction = handler =>
eventEmitter.addListener(RNCallKeepDidPerformDTMFAction, (data) => handler(data));

Expand Down Expand Up @@ -95,6 +99,7 @@ export const listeners = {
didDisplayIncomingCall,
didPerformSetMutedCallAction,
didToggleHoldCallAction,
performGroupCallAction,
didPerformDTMFAction,
didResetProvider,
checkReachability,
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ repositories {
}

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.facebook.react:react-native:0.66.3'
}
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare module 'react-native-callkeep' {
'didDeactivateAudioSession' |
'didDisplayIncomingCall' |
'didToggleHoldCallAction' |
'performGroupCallAction' |
'didPerformDTMFAction' |
'didResetProvider' |
'checkReachability' |
Expand Down Expand Up @@ -144,6 +145,8 @@ declare module 'react-native-callkeep' {
*/
static isCallActive(uuid: string): Promise<boolean>

static isAudioSessionActive(): Promise<boolean>

static getCalls(): Promise<object>

static getAudioRoutes(): Promise<void>
Expand Down Expand Up @@ -175,6 +178,9 @@ declare module 'react-native-callkeep' {
static toggleAudioRouteSpeaker(uuid: string, routeSpeaker: boolean): void

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

static setGroupCall(activeUuid: string, heldUuid: string): void
static setGroupCallFulfilled(): void

static setConnectionState(uuid: string, state: number): void

Expand All @@ -199,5 +205,9 @@ declare module 'react-native-callkeep' {
static setCurrentCallActive(callUUID: string): void

static backToForeground(): void

static configureVoiceAudioSession(): void

static configureVideoAudioSession(): void
}
}
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ class RNCallKeep {
addEventListener = (type, handler) => {
const listener = listeners[type](handler);

/**
* xxx https://idtjira.atlassian.net/browse/MOB-5329
*/
if (type === 'didActivateAudioSession') {
this.isAudioSessionActive().then(isActive => {
if (isActive) {
handler()
}
})
}

this._callkeepEventHandlers.set(type, listener);
};

Expand Down Expand Up @@ -170,6 +181,8 @@ class RNCallKeep {

isCallActive = async (uuid) => await RNCallKeepModule.isCallActive(uuid);

isAudioSessionActive = RNCallKeepModule.isAudioSessionActive;

getCalls = () => {
if (isIOS) {
return RNCallKeepModule.getCalls();
Expand Down Expand Up @@ -258,6 +271,9 @@ class RNCallKeep {
};

setOnHold = (uuid, shouldHold) => RNCallKeepModule.setOnHold(uuid, shouldHold);

setGroupCall = (activeUuid, heldUuid) => RNCallKeepModule.setGroupCall(activeUuid, heldUuid);
setGroupCallFulfilled = () => RNCallKeepModule.setGroupCallFulfilled();

setConnectionState = (uuid, state) => isIOS ? null : RNCallKeepModule.setConnectionState(uuid, state);

Expand Down Expand Up @@ -347,6 +363,14 @@ class RNCallKeep {
clearInitialEvents() {
return RNCallKeepModule.clearInitialEvents();
}

configureVideoAudioSession() {
return RNCallKeepModule.configureVideoAudioSession();
}

configureVoiceAudioSession() {
return RNCallKeepModule.configureVoiceAudioSession();
}
}

export default new RNCallKeep();
5 changes: 5 additions & 0 deletions ios/RNCallKeep/RNCallKeep.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

@property (nonatomic, strong) CXCallController *callKeepCallController;
@property (nonatomic, strong) CXProvider *callKeepProvider;
@property (nonatomic, strong) CXSetGroupCallAction * callKeepGroupCallAction;

+ (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
Expand All @@ -47,7 +48,11 @@ continueUserActivity:(NSUserActivity *)userActivity
reason:(int)reason;

+ (BOOL)isCallActive:(NSString *)uuidString;
+ (BOOL)isAudioSessionActive;

+ (void)setup:(NSDictionary *)options;

+ (void)configureVoiceAudioSession;
+ (void)configureVideoAudioSession;

@end
Loading

0 comments on commit 2d9a059

Please sign in to comment.