I have some problem with my app, the exactly I want is to only open call screen when get pushkit VOIP call. But the problem is that the app gets open again(when killed), so many request were sent to server, i just want to open only callscreen, then may exit app after call dismiss.
I will fully explain the problem now:
First, in app delegate i replace with this class(this class have same UI with splash Screen)
initiateFirstScreen("SplashScreen", storyboardName : "sheet")
Inside this class. I have to check token, user info, connect to signalr server, it's took about 5-8 seconds, and when all loaded, i call this function to navigate to the HomeScreen:
func checkLogin() {
if let oauth = AppDelegate.shared.authState, oauth.isAuthorized{
initiateFirstScreen("HomeVC", storyboardName : "main")
}else{
initiateFirstScreen("LoginVC", storyboardName : "main")
}
}
func initiateFirstScreen(_ vcName: String, storyboardName : String) {
guard let window = AppDelegate.shared.window else{
AlertUtils.alertMessageWithOkAction(vc: self, mes: Language.get("Something went wrong")){b in
exit(0)
}
return
}
let storyBoard: UIStoryboard = UIStoryboard(name: storyboardName, bundle: nil)
let vc = storyBoard.instantiateViewController(withIdentifier: vcName)
window.rootViewController = vc
window.makeKeyAndVisible()
}
Inside above code, im using window.rootViewController = vc to dislay HomeScreen without any animation.
The problem: Because of long loading in SplashScreen, when I got pushKit -> show Callkit screen, user may took 3-4 seconds to answer(when the app is killed/swiped)
-> didFinishLaunchingWithOptions called
-> SplashScreen called, and while user is answering call, the "check token, user info, connect to signalr" is loaded
-> Hence, the below function called:
window.rootViewController = vc
window.makeKeyAndVisible()
-> It's clear my callscreen now, that is the problem.
So i want to solved this problem, sorry for my silly question, but it's make me waste 3 days but can not solved this :(
You can use the delegate
This delegate gets call when you answer the call. So just navigate directly to call screen. and add a flag eg. isCall = true and prevent the user to navigate to Home Screen this time