Skip to content

Commit

Permalink
(AudioCallKit) Implement log file sharing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBrejcha committed Apr 27, 2021
1 parent ab862ec commit 28faccd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 38 deletions.
6 changes: 2 additions & 4 deletions AudioCallKit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ let sharedCallController: CXCallController = CXCallController(queue: .main)
let sharedCallManager: CallManager = CallManager(sharedClient, sharedAuthService)

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CXCallObserverDelegate, Loggable {
class AppDelegate: UIResponder, UIApplicationDelegate, CXCallObserverDelegate {
var window: UIWindow?
var appName: String { "AudioCallKit" }
var callManager = sharedCallManager
var callController = sharedCallController

override init() {
super.init()

Logger.configure(appName: "AudioCallKit")
callController.callObserver.setDelegate(self, queue: .main)
configureDefaultLogging()
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Expand Down
25 changes: 14 additions & 11 deletions AudioCallKit/Stories/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ final class LoginViewController:

override func viewDidLoad() {
super.viewDidLoad()
loginView.setTitle(text: "Audio call demo")

let loginHandler: AuthService.LoginCompletion = { [weak self] error in
guard let self = self else { return }
Expand All @@ -28,16 +27,20 @@ final class LoginViewController:
self.performSegue(withIdentifier: MainViewController.self, sender: self)
}
}

loginView.loginTouchHandler = { [weak self] username, password in
Log.d("Manually Logging in with password")
self?.showLoading(title: "Connecting", details: "Please wait...")
self?.authService.login(
user: username.appendingVoxDomain,
password: password,
loginHandler
)
}

loginView.configure(
title: "Audio call demo",
controller: self,
loginHandler: { [weak self] username, password in
Log.d("Manually Logging in with password")
self?.showLoading(title: "Connecting", details: "Please wait...")
self?.authService.login(
user: username.appendingVoxDomain,
password: password,
loginHandler
)
}
)

if authService.possibleToLogin {
Log.d("Automatically Logging in with token")
Expand Down
51 changes: 28 additions & 23 deletions AudioCallKit/Stories/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,37 @@ final class MainViewController:

override func viewDidLoad() {
super.viewDidLoad()

mainView.callTouchHandler = { [weak self] username in
Log.d("Calling \(String(describing: username))")
PermissionsHelper.requestRecordPermissions { error in
if let error = error {
self?.handleError(error)
return
}
let startCallAction = CXStartCallAction(
call: UUID(),
handle: CXHandle(type: .generic, value: username ?? "")
)
self?.callController.requestTransaction(with: startCallAction) { error in
if let error = error, let self = self {
AlertHelper.showError(message: error.localizedDescription, on: self)
Log.e(error.localizedDescription)

mainView.configure(
displayName: "", // setup on ViewWillAppear
controller: self,
callHandler: { [weak self] username in
Log.d("Calling \(String(describing: username))")
PermissionsHelper.requestRecordPermissions { error in
if let error = error {
self?.handleError(error)
return
}
let startCallAction = CXStartCallAction(
call: UUID(),
handle: CXHandle(type: .generic, value: username ?? "")
)
self?.callController.requestTransaction(with: startCallAction) { error in
if let error = error, let self = self {
AlertHelper.showError(message: error.localizedDescription, on: self)
Log.e(error.localizedDescription)
}
}
}
},
logoutHandler: { [weak self] in
self?.showLoading(title: "Logging out", details: "Please wait...")
self?.authService.logout {
self?.hideProgress()
self?.dismiss(animated: true)
}
}
}

mainView.logoutTouchHandler = { [weak self] in
self?.authService.logout {
self?.dismiss(animated: true)
}
}
)
}

override func viewWillAppear(_ animated: Bool) {
Expand Down

0 comments on commit 28faccd

Please sign in to comment.