Decline incoming Call when CallKit returns DND

This commit is contained in:
Jehan Monnier 2017-10-13 16:33:38 +02:00
parent 0bbc6714d2
commit 9307a25a51
3 changed files with 16 additions and 5 deletions

View file

@ -711,7 +711,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
video = ([UIApplication sharedApplication].applicationState == UIApplicationStateActive &&
linphone_core_get_video_policy(LC)->automatically_accept &&
linphone_call_params_video_enabled(linphone_call_get_remote_params(call)));
[LinphoneManager.instance.providerDelegate reportIncomingCallwithUUID:uuid handle:address video:video];
[LinphoneManager.instance.providerDelegate reportIncomingCall:call withUUID:uuid handle:address video:video];
#else
[PhoneMainView.instance displayIncomingCall:call];
#endif

View file

@ -23,7 +23,7 @@
@property BOOL pendingCallVideo;
@property int callKitCalls;
- (void)reportIncomingCallwithUUID:(NSUUID *)uuid handle:(NSString *)handle video:(BOOL)video;
- (void)reportIncomingCall:(LinphoneCall *) call withUUID:(NSUUID *)uuid handle:(NSString *)handle video:(BOOL)video;
- (void)config;
- (void)configAudioSession:(AVAudioSession *)audioSession;
@end

View file

@ -71,7 +71,7 @@
}
}
- (void)reportIncomingCallwithUUID:(NSUUID *)uuid handle:(NSString *)handle video:(BOOL)video {
- (void)reportIncomingCall:(LinphoneCall *) call withUUID:(NSUUID *)uuid handle:(NSString *)handle video:(BOOL)video; {
// Create update to describe the incoming call and caller
CXCallUpdate *update = [[CXCallUpdate alloc] init];
update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
@ -80,13 +80,24 @@
update.supportsGrouping = TRUE;
update.supportsUngrouping = TRUE;
update.hasVideo = video;
linphone_call_ref(call);
// Report incoming call to system
LOGD(@"CallKit: report new incoming call");
[self.provider reportNewIncomingCallWithUUID:uuid
update:update
completion:^(NSError *error) {
}];
if (error) {
LOGE(@"CallKit: cannot complete incoming call from [%@] caused by [%@]",handle,[error localizedDescription]);
if ( [error code] == CXErrorCodeIncomingCallErrorFilteredByDoNotDisturb
|| [error code] == CXErrorCodeIncomingCallErrorFilteredByBlockList) {
linphone_call_decline(call,LinphoneReasonBusy); /*to give a chance for other devices to answer*/
} else {
linphone_call_decline(call,LinphoneReasonUnknown);
}
}
linphone_call_unref(call);
}];
}
- (void)setPendingCall:(LinphoneCall *)pendingCall {