ios - 如何在 CoreSpotlight 的搜索结果中添加调用按钮?

标签 ios objective-c ios9 corespotlight

在 WWDC session 中搜索 API 简介。他们显示带有调用按钮的 Airbnb 应用程序的搜索结果。据我所见,我认为结果是使用 CSSearchableItemAttributeSet 创建的,而不是来自 Web Markup api。 我尝试将 CSSearchableItemAttributeSet 的 ItemContentType 设置为 kUTTypeItemkUTTypeMessagekUTTypeEmailMessage 当然还有 phoneNumbers 值。它们似乎都不起作用。我输入的所有详细信息都正确显示,但调用按钮除外。

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"];

如果我要使用 kUTTypeContent。调用按钮出现,但所有详细信息均未出现。只是我在创建 CSPerson 对象时输入的联系人姓名。

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

enter image description here

最佳答案

试试这个:

attributeSet.supportsPhoneCall = @(YES);

关于ios - 如何在 CoreSpotlight 的搜索结果中添加调用按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32862944/

相关文章:

ios - 解锁 iPhone X 模拟器

Ios 10 iPhone 7 键盘在收到通知时消失

objective-c - 如何将此点表示法转换为嵌套的Objective-C中括号?

objective-c - Xcode force_load 不适用于模拟器构建

iOS 内容拦截器白名单网站

ios - 为创建动态数据库的 iOS 应用程序设计 Core Data 托管对象模型

ios - 使用空值对 NSArray、NSComparator block 与 NSSortDescriptor 进行排序

ios - UIAlertView clickedButtonAtIndex 方法未被调用

ios - 如何在 iOS 9 中打开电话拨号器?

swift - 如何使 map 图钉动画掉落? swift 2.2 iOS 9