Go back to Flutter app from native controller

Issue

I am opening the new contact screen in iOS from my native side like that:

let contact = CNMutableContact.init()
let controller = CNContactViewController.init(forNewContact:contact)
controller.delegate = self
DispatchQueue.main.async {
    let navigation = UINavigationController .init(rootViewController: controller)
    let viewController : UIViewController? = UIApplication.shared.delegate?.window??.rootViewController
    viewController?.present(navigation, animated:true, completion: nil)
}

The screen opens correctly, the problem is that I can’t go back to the Flutter app. There is a cancel button but nothing happens when I click on it.

How to go back from a native controller?

Solution

How to fix this issue: add the following method the class (which already extends from CNContactViewControllerDelegate:

public func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) {
    viewController.dismiss(animated: true, completion: nil)
}

Answered By – svprdga

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.