Thanakrit Weekhamchai
Thanakrit Weekhamchai

Reputation: 242

How to add call button to search result in CoreSpotlight?

In WWDC session Introduction to Search APIs. They show a search result of Airbnb app with a call button. From what I saw I think the result was created with CSSearchableItemAttributeSet not from Web Markup api. I tried setting ItemContentType of CSSearchableItemAttributeSet to kUTTypeItem, kUTTypeMessage, kUTTypeEmailMessage of course with phoneNumbers value. None of them seems to work. All detail I put are appear correctly, except for the call button.

CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(__bridge NSString *)kUTTypeItem];
attributeSet.title = @"Call me back";
attributeSet.contentDescription = @"Firstname Lastname\n14:36 - 30 January 2014";
attributeSet.phoneNumbers = @[@"+66827364538"];
attributeSet.accountHandles = @[@"+66827364538"];

If I were to use kUTTypeContent. The call button appears but all details are not. Just name of contact that I put in when create CSPerson object.

CSPerson *person = [[CSPerson alloc] initWithDisplayName:@"Theptai Intathep"
                                                     handles:@[@"+66827364538"]
                                            handleIdentifier:CNContactPhoneNumbersKey];
attributeSet.authors = @[person];

enter image description here

Upvotes: 1

Views: 586

Answers (1)

Soo Young Byun
Soo Young Byun

Reputation: 21

Try this:

attributeSet.supportsPhoneCall = @(YES);

Upvotes: 2

Related Questions