How can I make a phone call by tapping the phone cell of the ABPersonViewController?

144 Views Asked by At

Until iOS 7 I was able to display a ABPersonViewController with the related contact info and by tapping on the phone cell I was able to make a phone call. In iOS 8.3 that I am testing now, this does not work. However tapping on the email cell opens the mail app, tapping on the website cell opens safari and tapping on the address cell opens maps as expected. This is the code I am using to create an instance of ABPersonViewController:

personViewController = new ABPersonViewController ();
personViewController.AllowsEditing = true;
personViewController.AllowsActions = true;
personViewController.Delegate = new PersonViewControllerDelegate ();
personViewController.DisplayedPerson = person;

What should I do to enable phone calling from within the ABPersonViewController in iOS 8 and 9?

1

There are 1 best solutions below

1
JBM On

From iOS 9 we need to use the code below. since the old ones are deprecated!

  CNMutableContact*conDetails=[[CNMutableContact alloc]init];

    if ([conDetails.phoneNumber length]!=0) {

        conDetails.phoneNumbers=[[NSArray alloc]initWithObjects:[CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMain value:[CNPhoneNumber phoneNumberWithStringValue:@"your phonenumber"]], nil];
    }
}