应用搜索结果未在Spot light iOS中显示

时间:2022-06-01 20:48:37

I implemented App Search using CoreSpotLight framework. The results are still not showing up in iOS spotlight

我使用CoreSpotLight框架实现了App Search。结果仍然没有出现在iOS聚光灯下

The approach i followed is

我遵循的方法是

  1. Created CSSearchableItemAttributeSet with title, keywords and contentDescription
  2. 使用title,keywords和contentDescription创建CSSearchableItemAttributeSet

  3. Created CSSearchableItem with above created attributes set.
  4. 使用上面创建的属性集创建CSSearchableItem。

  5. Added the CSSearchableItem to CSSearchableIndex
  6. 将CSSearchableItem添加到CSSearchableIndex

Every thing seems to be correct, not sure why the results are not showing up..

每件事似乎都是正确的,不确定为什么结果没有出现..

1 个解决方案

#1


0  

Finally managed to find the issue,

终于设法找到了问题,

The simulator ( iPad Retina 9.3 ) which i was using, is not supported for core spotlight. We can find the unsupported devices names in apple docs

我正在使用的模拟器(iPad Retina 9.3)不支持核心聚光灯。我们可以在apple docs中找到不受支持的设备名称

Although app search is available for iOS 9 users, the search functionality of NSUserActivity and Core Spotlight is not supported on iPhone 4s, iPad 2, iPad (3rd generation), iPad mini, and iPod touch (5th generation).

虽然iOS 9用户可以使用应用搜索功能,但iPhone 4s,iPad 2,iPad(第3代),iPad mini和iPod touch(第5代)不支持NSUserActivity和Core Spotlight的搜索功能。

Also, The following code was throwing an error

此外,以下代码抛出错误

[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:^(NSError * _Nullable error) { if (error) { NSLog(@"Error :%@",error); } }];

[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@ [item] completionHandler:^(NSError * _Nullable error){if(error){NSLog(@“Error:%@”,error); }};

The log is Error : Error Domain=CSIndexErrorDomain Code=-1005 "(null)”, which means CSIndexErrorCodeIndexingUnsupported , Indexing isn't supported on this device. Hope this save time for someone.

日志是错误:错误域= CSIndexErrorDomain代码= -1005“(null)”,这意味着CSIndexErrorCodeIndexingUnsupported,此设备不支持索引。希望这为某人节省时间。

Edit

As @rmaddy suggests, check for CSSearchableIndex isIndexingAvailable, this straightaways help to find the issue.

正如@rmaddy建议的那样,检查CSSearchableIndex isIndexingAvailable,这个直接帮助找到问题。

#1


0  

Finally managed to find the issue,

终于设法找到了问题,

The simulator ( iPad Retina 9.3 ) which i was using, is not supported for core spotlight. We can find the unsupported devices names in apple docs

我正在使用的模拟器(iPad Retina 9.3)不支持核心聚光灯。我们可以在apple docs中找到不受支持的设备名称

Although app search is available for iOS 9 users, the search functionality of NSUserActivity and Core Spotlight is not supported on iPhone 4s, iPad 2, iPad (3rd generation), iPad mini, and iPod touch (5th generation).

虽然iOS 9用户可以使用应用搜索功能,但iPhone 4s,iPad 2,iPad(第3代),iPad mini和iPod touch(第5代)不支持NSUserActivity和Core Spotlight的搜索功能。

Also, The following code was throwing an error

此外,以下代码抛出错误

[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:^(NSError * _Nullable error) { if (error) { NSLog(@"Error :%@",error); } }];

[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@ [item] completionHandler:^(NSError * _Nullable error){if(error){NSLog(@“Error:%@”,error); }};

The log is Error : Error Domain=CSIndexErrorDomain Code=-1005 "(null)”, which means CSIndexErrorCodeIndexingUnsupported , Indexing isn't supported on this device. Hope this save time for someone.

日志是错误:错误域= CSIndexErrorDomain代码= -1005“(null)”,这意味着CSIndexErrorCodeIndexingUnsupported,此设备不支持索引。希望这为某人节省时间。

Edit

As @rmaddy suggests, check for CSSearchableIndex isIndexingAvailable, this straightaways help to find the issue.

正如@rmaddy建议的那样,检查CSSearchableIndex isIndexingAvailable,这个直接帮助找到问题。