Forum Xamarin.iOS

How to edit alert titles using Contact UI Framework on iOS 13?


I have implemented a dependency service on my shared Xamarin Forms project which allows user to generate a new contact. For iOS i followed Microsoft's docs on Contacts and Contact UI libraries and their sample iOS app linked below their docs page (unfortunately I'm unable to post links yet) :).

The issue I am facing is in the scenario where I am on iOS 13.4 simulator I tap on my 'create contact' button which creates a new CNMutableContact and creates a new CNContactViewController using FromNewContact method I eventually get presented with a 'Create Contact' page which I presented on top of current navigation stack and I want to cancel the operation using the cancel button generated by Contact UI. What i would expect (or want to set) is clear titles which i can show to the user, but what I get is this (see screenshot below).

Here is the code for my iOS contact card service class:

public class ContactCardService : IContactCardService
    public async Task CreateContact(string name, string email)
        CNContactViewController contactViewController = await GenerateContactInternal(name, email);
        UIViewController navigationViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
        var viewContactNavigationController = new UINavigationController(contactViewController);

        while (navigationViewController.PresentedViewController != null)
            navigationViewController = viewContactNavigationController.PresentedViewController;

        navigationViewController.PresentViewController(viewContactNavigationController, true, null);

    private static async Task<CNContactViewController> GenerateContactInternal(string name, string email)
        var emailAddress = new CNLabeledValue<NSString>(CNLabelKey.Work, new NSString(email));
        var contact = new CNMutableContact { EmailAddresses = new[] { emailAddress }, GivenName = name };
        var editor = CNContactViewController.FromNewContact(contact);
        editor.Delegate = new MyCNContactViewControllerDelegate();
        editor.ContactStore = new CNContactStore();
        editor.Title = "Create Contact";
        return editor;

public class MyCNContactViewControllerDelegate : CNContactViewControllerDelegate
    public override void DidComplete(CNContactViewController viewController, CNContact contact)
        if (contact == null)
            viewController.DismissViewController(true, null);

    public override bool ShouldPerformDefaultAction(CNContactViewController viewController, CNContactProperty property) => false;

I've noticed that this does not seem to be an issue with iOS 10 because 'Cancel' action does not seem to be seen as a destructive action by the os and instead of displaying dialog box it just dismisses the view presented on top. (Not sure how it is on iOS 11 and 12 since i only have 10 and 13 simulators installed).

Also, my application uses MasterDetail navigation implemented in Xamarin Shared code (not sure if it affects where those titles might be set).

Can someone have a look for me please? I've very little experience writing native code as most of my app is written i shared part of Xamarin Forms project. Is it something that is easily editable or is there something fundamental i might be missing in the app setup?


  • LandLuLandLu Member, Xamarin Team Xamurai

    There will be minor differences between different OS versions.
    iOS 13 need this confirm action sheet to make sure the cancel behavior instead of dismissing the adding view controller directly.
    And this is controlled by the system you could check it out with the default contact app:

  • jskoczylasjskoczylas Member

    Hey LandLu,

    I can confirm that action sheet displays correctly on the default contact app.

  • LandLuLandLu Member, Xamarin Team Xamurai

    Do you mean the text on the sheet is messed up?
    Could you please share a sample to help me reproduce this issue.
    I used your code above, however, it displays correctly as the contact application.

Sign In or Register to comment.