Commit f26ffde1 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

fix: answer call on locked screen

- fix navigation to video call
- fix audio

Change-Id: I373d34ff920c59929f4b816d17bd113e820ed816
parent 8cfad345
......@@ -507,9 +507,6 @@ extension AppDelegate: PKPushRegistryDelegate {
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
self.accountService.pushNotificationReceived(data: payload.dictionaryPayload)
if #available(iOS 10.0, *) {
return
}
if UIApplication.shared.applicationState != .active {
self.audioService.startAVAudioSession()
}
......
......@@ -331,6 +331,9 @@ class CallViewModel: Stateable, ViewModel {
return callUUID == self.call?.callUUID.uuidString
}).subscribe(onNext: { [unowned self] serviceEvent in
if serviceEvent.eventType == ServiceEventType.callProviderAnswerCall {
if !self.audioService.isHeadsetConnected.value {
self.switchSpeaker()
}
self.answerCall()
.subscribe()
.disposed(by: self.disposeBag)
......@@ -338,6 +341,16 @@ class CallViewModel: Stateable, ViewModel {
self.cancelCall(stopProvider: false)
}
}).disposed(by: self.disposeBag)
callsProvider.sharedResponseStream
.filter({ serviceEvent in
serviceEvent.eventType == .audioActivated
}).subscribe(onNext: { [unowned self] _ in
if !self.audioService.isHeadsetConnected.value {
self.isAudioOnly ?
self.audioService.overrideToReceiver() : self.audioService.overrideToSpeaker()
}
}).disposed(by: self.disposeBag)
}
static func formattedDurationFrom(interval: Int) -> String {
......@@ -372,12 +385,15 @@ class CallViewModel: Stateable, ViewModel {
}
func answerCall() -> Completable {
guard #available(iOS 10.0, *) else {
if !self.audioService.isHeadsetConnected.value {
isAudioOnly ?
self.audioService.overrideToReceiver() : self.audioService.overrideToSpeaker()
}
return self.callService.accept(call: call)
}
return self.callService.accept(call: call)
}
func placeCall(with uri: String, userName: String, isAudioOnly: Bool = false) {
guard let account = self.accountService.currentAccount else {
......
......@@ -47,6 +47,7 @@ internal enum Asset {
internal static let icShowInput = ImageAsset(name: "ic_show_input")
internal static let infoArrow = ImageAsset(name: "info_arrow")
internal static let jamiIcon = ImageAsset(name: "jamiIcon")
internal static let jamiLogo = ImageAsset(name: "jamiLogo")
internal static let leftArrow = ImageAsset(name: "left_arrow")
internal static let moreSettings = ImageAsset(name: "more_settings")
internal static let pauseCall = ImageAsset(name: "pause_call")
......
......@@ -205,8 +205,8 @@ final class AppCoordinator: Coordinator, StateableResponsive {
childCoordinattor.stateSubject
.onNext(ConversationState
.startAudioCall(contactRingId: participant, userName: name))
}
return
}
}
}
}
......@@ -231,17 +231,6 @@ class ConversationsCoordinator: Coordinator, StateableResponsive, ConversationNa
topController.present(callViewController, animated: true, completion: nil)
}
func getTopController() -> UIViewController? {
guard var topController = UIApplication.shared
.keyWindow?.rootViewController else {
return nil
}
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
return topController
}
func triggerCallNotifications(call: CallModel) {
var data = [String: String]()
data [NotificationUserInfoKeys.name.rawValue] = call.displayName
......
......@@ -111,7 +111,22 @@ extension ConversationNavigation where Self: Coordinator, Self: StateableRespons
lockWhilePresenting: VCType.conversation.rawValue)
}
func getTopController() -> UIViewController? {
guard var topController = UIApplication.shared
.keyWindow?.rootViewController else {
return nil
}
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
return topController
}
func startOutgoingCall(contactRingId: String, userName: String, isAudioOnly: Bool = false) {
guard let topController = getTopController(),
!topController.isKind(of: (CallViewController).self) else {
return
}
DispatchQueue.main.async {
let callViewController = CallViewController.instantiate(with: self.injectionBag)
callViewController.viewModel.placeCall(with: contactRingId, userName: userName, isAudioOnly: isAudioOnly)
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "jamiLogo-2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "jamiLogo-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "jamiLogo.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -40,6 +40,9 @@ class CallsProviderDelegate: NSObject {
providerConfiguration.supportsVideo = true
providerConfiguration.supportedHandleTypes = [.generic, .phoneNumber]
providerConfiguration.ringtoneSound = "default.wav"
providerConfiguration.iconTemplateImageData = UIImage(asset: Asset.jamiLogo)?.pngData()
providerConfiguration.maximumCallGroups = 1
providerConfiguration.maximumCallsPerCallGroup = 1
provider = CXProvider(configuration: providerConfiguration)
provider?.setDelegate(self, queue: nil)
......@@ -74,7 +77,10 @@ extension CallsProviderDelegate {
update.localizedCallerName = handleInfo.displayName
update.remoteHandle = CXHandle(type: handleType, value: handleInfo.handle)
update.hasVideo = !call.isAudioOnly
provider?.reportNewIncomingCall(with: call.callUUID,
update.supportsGrouping = false
update.supportsUngrouping = false
update.supportsHolding = false
self.provider?.reportNewIncomingCall(with: call.callUUID,
update: update) { error in
if error == nil {
return
......@@ -157,4 +163,21 @@ extension CallsProviderDelegate: CXProviderDelegate {
self.provider?.reportCall(with: action.callUUID, updated: update)
action.fulfill()
}
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
let serviceEventType: ServiceEventType = .audioActivated
let serviceEvent = ServiceEvent(withEventType: serviceEventType)
self.responseStream.onNext(serviceEvent)
print("didActivate")
// Start call audio media, now that the audio session has been activated after having its priority boosted.
}
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
print("didActivate")
/*
Restart any non-call related audio now that the app's audio session has been
de-activated after having its priority restored to normal.
*/
}
}
......@@ -46,6 +46,7 @@ enum ServiceEventType {
case nameRegistrationEnded
case callProviderAnswerCall
case callProviderCancellCall
case audioActivated
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment