show in-call controller when joining on the phone, dismiss on hangup

This commit is contained in:
Saúl Ibarra Corretgé 2017-09-28 13:43:07 +02:00
parent d183d41fdf
commit aef73cc85f
2 changed files with 21 additions and 2 deletions

View File

@ -80,11 +80,27 @@ class ExtensionDelegate: NSObject, WCSessionDelegate, WKExtensionDelegate {
let micMuted = applicationContext["micMuted"] as? NSNumber ?? -1;
print("MIC MUTED \(micMuted)");
// Update recent URLs
let recentURLs = applicationContext["recentURLs"];
if let recentURLsArray = recentURLs as? NSArray {
let controller = WKExtension.shared().rootInterfaceController as! InterfaceController
controller.updateRecents(withRecents: recentURLsArray)
}
// If the current controller is not the in-call controller and we have a
// conference URL, show the in-call controller
if let currentController = WKExtension.shared().visibleInterfaceController as? InterfaceController {
if conferenceURL != "NULL" {
let room = conferenceURL.components(separatedBy: "/").last
let context = ["room" : room, "roomUrl" : conferenceURL as String!, "skipJoin" : "yes"]
currentController.pushController(withName: "InCallController", context: context)
}
} else {
// This must be InCallController
if conferenceURL == "NULL" {
WKExtension.shared().visibleInterfaceController?.popToRootController()
}
}
}
}

View File

@ -43,8 +43,11 @@ class InCallController: WKInterfaceController {
super.awake(withContext: context)
if let data = context as? [String : String] {
sendMessage(["command": "joinConference", "data" : data["roomUrl"]!])
roomLabel.setText(data["room"]!)
if data["skipJoin"] != "yes" {
sendMessage(["command": "joinConference", "data" : data["roomUrl"]!])
}
roomLabel.setText(data["room"]!)
}
}