0
votes

Guys i am facing an odd problem with NavigationController. Existing answers did not help at all !!!!

Here is basic scenario of the app:

  1. There are two views - Main and Second view
  2. In main view there is a button when i happen to tap goes into second view using segue.
  3. In second view after i enter a certain field in text view and click on a button called "join" it triggers "joinMeeting()" function and meeting should be joined.

However, when i do that debugger shows me:

"Warning: Attempt to present on <***.ViewController: *****> whose view is not in the window hierarchy!"

So i have read most of the tread and given that it happens because of viewDidAppear method but i have nth to be done before viewDidAppear. Everything happens after button is clicked.

joinMeeting() is successfully called and print method returns 0 which means no issue(https://developer.zoom.us/docs/ios/error-codes/) and successful SDK connection however after this "Warning" error is shown in debugger and nothing happens in the app.

If it helps following is the code that triggers joinBtn:

/**
Triggers when Join Button is clicked from second view.
*/
    @IBAction func joinMeeting(_ sender: Any) {
            if( activityID.text == "" ) {
                let alert = UIAlertController(title: "Field is Blank", message: "Activity ID cannot be blank.", preferredStyle: UIAlertControllerStyle.alert)
                alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
                self.present(alert, animated: true, completion: nil)

                return;
            }


            let ms: MobileRTCMeetingService? = MobileRTC.shared().getMeetingService()
            if ms != nil {
                ms?.delegate = self;

                // //For Join a meeting
                let paramDict: [AnyHashable: Any] = [
                    kMeetingParam_Username: kSDKUserName,
                    kMeetingParam_MeetingNumber: activityID.text!,
                ]

                let ret: MobileRTCMeetError? = ms?.joinMeeting(with: paramDict)
                print("onJoinaMeeting ret:\(String(describing: ret))")
            }
        }

Please help if anyone knows or have an idea on what i am missing here.

3
Which line of code is throwing this error? - Dávid Pásztor
After "let ret: MobileRTCMeetError? = ms?.joinMeeting(with: paramDict)" ... error is triggered - DpEN
Then you should edit your question to include the definition of joinMeeting(with:). Without a Minimal, Complete and Verifiable example your question is considered off-topic. - Dávid Pásztor
Sorry about that.. updated the question by a bit. Added "joinMeeting() is successfully" - DpEN
ms?.joinMeeting(with: paramDict) cannot be calling the IBAction called joinMeeting since their function signatures are clearly different. It seems MobileRTCMeetingService has another method called joinMeeting(with:) and that is the one you are calling on the problematic line, not joinMeeting(_:), which is an IBAction connected to your UIButton. - Dávid Pásztor

3 Answers

0
votes

Here is what solved the issue:

Storyboard Configuration: ViewController --Segue: Show--> JoinViewController

@IBAction func onClickJoin(_ sender: AnyObject) {
        //Main storyBoard
        let initialVC = UIStoryboard(name: "Main", bundle:nil).instantiateInitialViewController() as! UIViewController

        let appDelegate = (UIApplication.shared.delegate as! AppDelegate)

        appDelegate.window?.rootViewController = initialVC

        //Rest of the code
    }
0
votes

Just Add Following code on that controller in which you want to perform calling:

    override func viewWillAppear(_ animated: Bool) {
    let appDelegate = UIApplication.shared.delegate as? AppDelegate
  appDelegate?.window?.rootViewController  = self

}
0
votes

Unfortunately, none of the above solutions worked for me. So Here is my solution.

Add this line

MobileRTC.shared().setMobileRTCRootController( self.navigationController)

=> When user taps of Join Call Button.

Make sure these conditions should meet as well.

  1. ViewController which is used to open the ZOOM meeting should be a part of root navigation controller
  2. DO NOT present modally the current Zoom Meeting Joining View Controller. Always push it to the root navigation controller.