HomeiOS Developmentswift - iOS App doesn't open (typically) when answering an incoming name...

swift – iOS App doesn’t open (typically) when answering an incoming name whereas having the app in background or inactive (closed) mode


I’m serving to to get a video name utility to work. The app was beforehand performed in Swift (legacy app), and now it received re-done utilizing ionic Capacitor.

With a view to obtain incoming push notifications, we needed to implement that a part of the app in Swift. Due to this fact, as quickly because the app receives an incoming push notification and the consumer solutions, some code is triggered (in Swift) which sends the knowledge of the incoming name to Capacitor. Then the video name is began and capacitor takes over from there.

If the app is in focus, I will reply the decision and it’ll ship me appropriately to the video name.

However, if the app is in background mode (minimized) or inactive (app is closed), when there may be an incoming name and I reply it, typically the app will open and typically it won’t. When it opens, the video name will work correctly. When the app doesn’t open, I can open the app manually and it’ll load the video name after that. Nevertheless, the app needs to be opening at all times if the consumer solutions the decision.

Within the legacy app (performed in Swift), I obtain the incoming name and after answering it, this perform will get executed:

func supplier(_ supplier: CXProvider, carry out motion: CXAnswerCallAction)

Another code will get executed in that perform, however that is what I believe will really get the app to open when the decision is answered:

func openIncomingCallViewController(motion: CXAnswerCallAction?, incomingCall: IncomingCall) {
    guard let nav = UIStoryboard(identify: "IncomingCall", bundle: nil).instantiateInitialViewController() as? UINavigationController,
          let incomingCallVC = nav.viewControllers.first as? IncomingCallViewController else {
        return
    }
    
    let doctorCallController = incomingCallVC.getCallController()
    self.providerDelegate.setCallController(callController: doctorCallController)
    
    doctorCallController.connectTo(incomingCall: incomingCall,
                                                 motion: motion)
    incomingCallVC.incomingCall = incomingCall
    
    if let nav = UIStoryboard(identify: "WaitingCall", bundle: nil).instantiateViewController(withIdentifier: "NavigationWaitingCall") as? UINavigationController{
        self.window?.rootViewController = nav
        nav.pushViewController(incomingCallVC, animated: true)
    }
}

Within the new app, I’m executing the next perform when the decision is answered:

public func supplier(_ supplier: CXProvider, carry out motion: CXAnswerCallAction) {
    change UIApplication.shared.applicationState {
    case .background, .inactive:
        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate,
              let window = appDelegate.window else {
            return
        }
        let storyboard = UIStoryboard(identify: "Major", bundle: nil)
        let yourVC = storyboard.instantiateViewController(identifier: "CAPBridgeViewController")
        let navController = UINavigationController(rootViewController:  yourVC)
        navController.modalPresentationStyle = .fullScreen

        // you may assign your vc instantly or push it in navigation stack as follows:
        window.rootViewController = navController
        window.makeKeyAndVisible()
        
        notifyEvent(eventName: "callResponse")
        endCall(uuid: motion.callUUID)
        motion.fulfill()
    case .energetic:
        notifyEvent(eventName: "callResponse")
        endCall(uuid: motion.callUUID)
        motion.fulfill()
        break;
    @unknown default:
        break;
    }
}

In that perform I additionally open a view controller within the window, after which capacitor will open the video name calling this perform notifyEvent(eventName: "callResponse")

As I discussed earlier, if the app is energetic (open) it can work correctly when answering the decision.
If the app is inactive (closed) or in background (minimized), typically it can open when answering the decision and typically it won’t.

Including NSLogs, I seen that each time the video name is answered however the app shouldn’t be opened, the next capabilities won’t be executed:

func applicationWillEnterForeground(_ utility: UIApplication)
func applicationDidBecomeActive(_ utility: UIApplication)

Is there something that may be executed when the consumer solutions the decision in order that the app is about as energetic / opened once more?


Notice to the moderators:
I already checked out a number of completely different threads and didn’t discover the reply to my query. Due to this fact, please don’t indiscriminately delete this submit as I want it for work.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments