Ios 重复项目显示在聚光灯中,缩略图不显示
我试图同时使用Ios 重复项目显示在聚光灯中,缩略图不显示,ios,spotlight,nsuseractivity,Ios,Spotlight,Nsuseractivity,我试图同时使用nsserActivity、核心聚光灯API和web标记 因此,根据中给出的建议 如果您使用所有三个API,那么使用 作为uniqueIdentifier的值的相关网页, relatedUniqueIdentifier和webpageURL 以下是我创建项目的方式: NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.test.product"]; activity.title
nsserActivity
、核心聚光灯API
和web标记
因此,根据中给出的建议
如果您使用所有三个API,那么使用
作为uniqueIdentifier的值的相关网页,
relatedUniqueIdentifier和webpageURL
以下是我创建项目的方式:
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.test.product"];
activity.title = self.detailModel.title;
activity.userInfo = @{ @"id" : self.detailModel.productId };
activity.eligibleForHandoff = NO;
activity.eligibleForPublicIndexing = YES;
activity.eligibleForSearch = YES;
activity.webpageURL = [NSURL URLWithString:[self shareUrl]];
activity.contentAttributeSet.contentDescription = self.detailModel.proDesc;
activity.contentAttributeSet.title = self.detailModel.title;
activity.contentAttributeSet.thumbnailData = UIImagePNGRepresentation(image);
activity.contentAttributeSet.relatedUniqueIdentifier = [self shareUrl];
CSSearchableItemAttributeSet *attrSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeURL];
attrSet.title = self.detailModel.title;
attrSet.contentDescription = self.detailModel.proDesc;
attrSet.thumbnailData = activity.contentAttributeSet.thumbnailData;
attrSet.relatedUniqueIdentifier = [self shareUrl];
CSSearchableItem *searchableItem = [[CSSearchableItem alloc] initWithUniqueIdentifier:[self shareUrl] domainIdentifier:@"com.test.product" attributeSet:attrSet];
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[ searchableItem ] completionHandler:^(NSError *_Nullable error) {
if (error) {
DDLogError(@"%@", error.localizedDescription);
} else {
DDLogInfo(@"Core Spotlight indexed");
}
}];
}
}];
self.systemUserActivity = activity;
[self.systemUserActivity becomeCurrent];
但当我试图在聚光灯下搜索时,有两个问题:
- 将显示重复的项目,一个来自活动,另一个来自聚光灯索引
- 这两个项目仅显示应用程序图标,而不是我设置的图像