ios - 如何在 Corespotlight 搜索中显示消息和视频按钮?
问题描述
当用户搜索我能够显示呼叫按钮但无法显示消息和视频按钮的联系人时,我想显示消息和视频按钮。
下面是我正在使用的一段代码
CSSearchableItemAttributeSet * attributeSet = [[CSSearchableItemAttributeSet alloc]
initWithItemContentType:(NSString *)kUTTypeItem];
attributeSet.displayName = [contact.name.compositeName capitalizedString];
attributeSet.contentDescription = @"my awesome Contacts ";
attributeSet.keywords = @[[contact.name.compositeName capitalizedString]];
UIImage *image = [UIImage imageNamed:@"dialer_filled_icn"];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
attributeSet.thumbnailData = imageData;
attributeSet.phoneNumbers = @[JustNumber([contact.phones[0] number])];
attributeSet.instantMessageAddresses = @[JustNumber([contact.phones[0] number])];
attributeSet.supportsPhoneCall = @(YES);
CSSearchableItem *item1 = [[CSSearchableItem alloc]
initWithUniqueIdentifier:JustNumber([contact.phones[0] number])
domainIdentifier:@"com.domain.appname"
attributeSet:attributeSet];
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item1]
completionHandler: ^(NSError * __nullable error) {
if (!error)
NSLog(@"Search item(s) journaled for indexing.");
}];
任何建议将不胜感激。
解决方案
推荐阅读
- java - 使用springboot重启服务器时清除属性
- c++ - 谷歌单元测试期望从暴露者调用方法
- python - Pandas DataFrame 的所有值的滚动平均值
- xamarin.forms - VS for Mac 无法添加 .NET Standard NuGet
- gps - 让 GPS 模块给出正确的值(很可能是缓冲区问题)
- saxon - 撒克逊人容易受到 XXE 攻击吗?
- c++ - Homebrew OS X OpenCV - 在另一台 Mac 上运行时寻找 dylib
- excel - 绕过公式数组
- c# - 使用 LINQ 时出现 StackOverFlow 未处理错误”
- regex - 通配符或等效于在 excel 文件中读取