Skip to content

Commit

Permalink
Merge pull request #1 from react-native-webrtc/master
Browse files Browse the repository at this point in the history
4.3.14 from base repo
  • Loading branch information
rimonhanna authored Sep 9, 2024
2 parents 205a1bf + 85f0e79 commit 4571d7b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
4 changes: 3 additions & 1 deletion android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public void checkPhoneAccountPermission(ReadableArray optionalPermissions, Promi
allPermissionaw.pushString(allPermission);
}

getReactApplicationContext()
this.reactContext
.getNativeModule(PermissionsModule.class)
.requestMultiplePermissions(allPermissionaw, new Promise() {
@Override
Expand Down Expand Up @@ -718,6 +718,8 @@ public void reportEndCallWithUUID(String uuid, int reason) {
return;
}
conn.reportDisconnect(reason);

this.stopListenToNativeCallsState();
}

@Override
Expand Down
28 changes: 16 additions & 12 deletions android/src/main/java/io/wazo/callkeep/VoiceConnectionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,22 @@ private void wakeUpApplication(String uuid, String number, String displayName) {
// Avoid to call wake up the app again in wakeUpAfterReachabilityTimeout.
this.currentConnectionRequest = null;

Intent headlessIntent = new Intent(
this.getApplicationContext(),
RNCallKeepBackgroundMessagingService.class
);
headlessIntent.putExtra("callUUID", uuid);
headlessIntent.putExtra("name", displayName);
headlessIntent.putExtra("handle", number);

ComponentName name = this.getApplicationContext().startService(headlessIntent);
if (name != null) {
Log.d(TAG, "[VoiceConnectionService] wakeUpApplication, acquiring lock for application:" + name);
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
try {
Intent headlessIntent = new Intent(
this.getApplicationContext(),
RNCallKeepBackgroundMessagingService.class
);
headlessIntent.putExtra("callUUID", uuid);
headlessIntent.putExtra("name", displayName);
headlessIntent.putExtra("handle", number);

ComponentName name = this.getApplicationContext().startService(headlessIntent);
if (name != null) {
Log.d(TAG, "[VoiceConnectionService] wakeUpApplication, acquiring lock for application:" + name);
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
}
} catch (Exception e) {
Log.w(TAG, "[VoiceConnectionService] wakeUpApplication, error" + e.toString());
}
}

Expand Down
27 changes: 18 additions & 9 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ - (void)startObserving
- (void)stopObserving
{
_hasListeners = FALSE;

// Fix for https://github.com/react-native-webrtc/react-native-callkeep/issues/406
// We use Objective-C Key Value Coding(KVC) to sync _RTCEventEmitter_ `_listenerCount`.
@try {
[self setValue:@0 forKey:@"_listenerCount"];
}
}
@catch ( NSException *e ){
NSLog(@"[RNCallKeep][stopObserving] exception: %@",e);
NSLog(@"[RNCallKeep][stopObserving] RNCallKeep parent class RTCEventEmitter might have a broken state.");
Expand Down Expand Up @@ -189,7 +189,16 @@ + (void)initCallKitProvider {
}

+ (NSString *) getAudioOutput {
return [AVAudioSession sharedInstance].currentRoute.outputs.count > 0 ? [AVAudioSession sharedInstance].currentRoute.outputs[0].portType : nil;
@try{
NSArray<AVAudioSessionPortDescription *>* outputs = [AVAudioSession sharedInstance].currentRoute.outputs;
if(outputs != nil && outputs.count > 0){
return outputs[0].portType;
}
} @catch(NSException* error) {
NSLog(@"getAudioOutput error :%@", [error description]);
}

return nil;
}

+ (void)setup:(NSDictionary *)options {
Expand Down Expand Up @@ -554,7 +563,7 @@ + (NSMutableArray *) formatAudioInputs: (NSMutableArray *)inputs
{
NSMutableArray *newInputs = [NSMutableArray new];
NSString * selected = [RNCallKeep getSelectedAudioRoute];

NSMutableDictionary *speakerDict = [[NSMutableDictionary alloc]init];
[speakerDict setObject:@"Speaker" forKey:@"name"];
[speakerDict setObject:AVAudioSessionPortBuiltInSpeaker forKey:@"type"];
Expand Down Expand Up @@ -645,13 +654,13 @@ + (NSString *) getSelectedAudioRoute
AVAudioSession* myAudioSession = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription *currentRoute = [myAudioSession currentRoute];
NSArray *selectedOutputs = currentRoute.outputs;

AVAudioSessionPortDescription *selectedOutput = selectedOutputs[0];

if(selectedOutput && [selectedOutput.portType isEqualToString:AVAudioSessionPortBuiltInReceiver]) {
return @"Phone";
}

return [RNCallKeep getAudioInputType: selectedOutput.portType];
}

Expand Down Expand Up @@ -909,7 +918,7 @@ - (void)configureAudioSession

NSUInteger categoryOptions = AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionAllowBluetoothA2DP;
NSString *mode = AVAudioSessionModeDefault;

NSDictionary *settings = [RNCallKeep getSettings];
if (settings && settings[@"audioSession"]) {
if (settings[@"audioSession"][@"categoryOptions"]) {
Expand All @@ -920,7 +929,7 @@ - (void)configureAudioSession
mode = settings[@"audioSession"][@"mode"];
}
}

AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:categoryOptions error:nil];

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-callkeep",
"version": "4.3.12",
"version": "4.3.14",
"description": "iOS 10 CallKit and Android ConnectionService Framework For React Native",
"main": "index.js",
"scripts": {},
Expand Down

0 comments on commit 4571d7b

Please sign in to comment.