CSSearchableItemAttributeSet doesn't show phone number

329 views Asked by At

I am doing for search api in ios 9. I can show for title and desc. However, I can't do for phone number. Will it show as call button , right? But, so far, I only see title and desc. How shall I do?

CSSearchableItemAttributeSet * attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString*)kUTTypeItem];

attributeSet.title = [NSString stringWithFormat:@"%@",nickname];
attributeSet.contentDescription = [NSString stringWithFormat:@"Department - %@", department];
attributeSet.keywords = @[nickname, department];
attributeSet.phoneNumbers = @[@"23233036"];
2

There are 2 answers

0
dvp.petrov On

You should set atrributeSet property supportsPhoneCall to 1. Link to documentation for more info: https://developer.apple.com/documentation/corespotlight/cssearchableitemattributeset/1621653-supportsphonecall P.s. you will not see the phone number as string, there will be button to make a phone call. And on press you will call the first phone number from attributeSet.phoneNumbers. Have in mind this will not work on simulator - test it on real device.

0
user5465987 On

Have you tried changing the content type to kUTTypeContact?