-1

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 :(

famfamfam
  • 396
  • 3
  • 8
  • 31
  • I am confused, when you receive VOIP, you need to call reportIncomingCall. It will only open your call kit? Is there any other call screen you have? – iOS Developer May 12 '21 at 14:50
  • hi, i detected the app is called again by sendLog to server, didFinishLaunchingWithOptions called then app opened. Sorry for my bad English – famfamfam May 12 '21 at 14:53
  • What is sendLog to server? – iOS Developer May 12 '21 at 14:55
  • i put the function sendlog to server to detect didFinishLaunchingWithOptions is called, because when app were killed, i can not get anylog from Xcode – famfamfam May 12 '21 at 14:56
  • after sendlog to server, i saw didFinishLaunchingWithOptions were called when I get pushkit, so the problem is the app run -> it's make many requests to server, and I dont want that – famfamfam May 12 '21 at 14:58

1 Answers1

0

You can use the delegate

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession)

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

iOS Developer
  • 464
  • 6
  • 24