Skip to content

Commit 4571d7b

Browse files
authored
Merge pull request #1 from react-native-webrtc/master
4.3.14 from base repo
2 parents 205a1bf + 85f0e79 commit 4571d7b

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ public void checkPhoneAccountPermission(ReadableArray optionalPermissions, Promi
588588
allPermissionaw.pushString(allPermission);
589589
}
590590

591-
getReactApplicationContext()
591+
this.reactContext
592592
.getNativeModule(PermissionsModule.class)
593593
.requestMultiplePermissions(allPermissionaw, new Promise() {
594594
@Override
@@ -718,6 +718,8 @@ public void reportEndCallWithUUID(String uuid, int reason) {
718718
return;
719719
}
720720
conn.reportDisconnect(reason);
721+
722+
this.stopListenToNativeCallsState();
721723
}
722724

723725
@Override

android/src/main/java/io/wazo/callkeep/VoiceConnectionService.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,22 @@ private void wakeUpApplication(String uuid, String number, String displayName) {
382382
// Avoid to call wake up the app again in wakeUpAfterReachabilityTimeout.
383383
this.currentConnectionRequest = null;
384384

385-
Intent headlessIntent = new Intent(
386-
this.getApplicationContext(),
387-
RNCallKeepBackgroundMessagingService.class
388-
);
389-
headlessIntent.putExtra("callUUID", uuid);
390-
headlessIntent.putExtra("name", displayName);
391-
headlessIntent.putExtra("handle", number);
392-
393-
ComponentName name = this.getApplicationContext().startService(headlessIntent);
394-
if (name != null) {
395-
Log.d(TAG, "[VoiceConnectionService] wakeUpApplication, acquiring lock for application:" + name);
396-
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
385+
try {
386+
Intent headlessIntent = new Intent(
387+
this.getApplicationContext(),
388+
RNCallKeepBackgroundMessagingService.class
389+
);
390+
headlessIntent.putExtra("callUUID", uuid);
391+
headlessIntent.putExtra("name", displayName);
392+
headlessIntent.putExtra("handle", number);
393+
394+
ComponentName name = this.getApplicationContext().startService(headlessIntent);
395+
if (name != null) {
396+
Log.d(TAG, "[VoiceConnectionService] wakeUpApplication, acquiring lock for application:" + name);
397+
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
398+
}
399+
} catch (Exception e) {
400+
Log.w(TAG, "[VoiceConnectionService] wakeUpApplication, error" + e.toString());
397401
}
398402
}
399403

ios/RNCallKeep/RNCallKeep.m

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ - (void)startObserving
131131
- (void)stopObserving
132132
{
133133
_hasListeners = FALSE;
134-
134+
135135
// Fix for https://github.com/react-native-webrtc/react-native-callkeep/issues/406
136136
// We use Objective-C Key Value Coding(KVC) to sync _RTCEventEmitter_ `_listenerCount`.
137137
@try {
138138
[self setValue:@0 forKey:@"_listenerCount"];
139-
}
139+
}
140140
@catch ( NSException *e ){
141141
NSLog(@"[RNCallKeep][stopObserving] exception: %@",e);
142142
NSLog(@"[RNCallKeep][stopObserving] RNCallKeep parent class RTCEventEmitter might have a broken state.");
@@ -189,7 +189,16 @@ + (void)initCallKitProvider {
189189
}
190190

191191
+ (NSString *) getAudioOutput {
192-
return [AVAudioSession sharedInstance].currentRoute.outputs.count > 0 ? [AVAudioSession sharedInstance].currentRoute.outputs[0].portType : nil;
192+
@try{
193+
NSArray<AVAudioSessionPortDescription *>* outputs = [AVAudioSession sharedInstance].currentRoute.outputs;
194+
if(outputs != nil && outputs.count > 0){
195+
return outputs[0].portType;
196+
}
197+
} @catch(NSException* error) {
198+
NSLog(@"getAudioOutput error :%@", [error description]);
199+
}
200+
201+
return nil;
193202
}
194203

195204
+ (void)setup:(NSDictionary *)options {
@@ -554,7 +563,7 @@ + (NSMutableArray *) formatAudioInputs: (NSMutableArray *)inputs
554563
{
555564
NSMutableArray *newInputs = [NSMutableArray new];
556565
NSString * selected = [RNCallKeep getSelectedAudioRoute];
557-
566+
558567
NSMutableDictionary *speakerDict = [[NSMutableDictionary alloc]init];
559568
[speakerDict setObject:@"Speaker" forKey:@"name"];
560569
[speakerDict setObject:AVAudioSessionPortBuiltInSpeaker forKey:@"type"];
@@ -645,13 +654,13 @@ + (NSString *) getSelectedAudioRoute
645654
AVAudioSession* myAudioSession = [AVAudioSession sharedInstance];
646655
AVAudioSessionRouteDescription *currentRoute = [myAudioSession currentRoute];
647656
NSArray *selectedOutputs = currentRoute.outputs;
648-
657+
649658
AVAudioSessionPortDescription *selectedOutput = selectedOutputs[0];
650-
659+
651660
if(selectedOutput && [selectedOutput.portType isEqualToString:AVAudioSessionPortBuiltInReceiver]) {
652661
return @"Phone";
653662
}
654-
663+
655664
return [RNCallKeep getAudioInputType: selectedOutput.portType];
656665
}
657666

@@ -909,7 +918,7 @@ - (void)configureAudioSession
909918

910919
NSUInteger categoryOptions = AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionAllowBluetoothA2DP;
911920
NSString *mode = AVAudioSessionModeDefault;
912-
921+
913922
NSDictionary *settings = [RNCallKeep getSettings];
914923
if (settings && settings[@"audioSession"]) {
915924
if (settings[@"audioSession"][@"categoryOptions"]) {
@@ -920,7 +929,7 @@ - (void)configureAudioSession
920929
mode = settings[@"audioSession"][@"mode"];
921930
}
922931
}
923-
932+
924933
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
925934
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:categoryOptions error:nil];
926935

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-callkeep",
3-
"version": "4.3.12",
3+
"version": "4.3.14",
44
"description": "iOS 10 CallKit and Android ConnectionService Framework For React Native",
55
"main": "index.js",
66
"scripts": {},

0 commit comments

Comments
 (0)