[TIMOB-19006] iOS9: Implement NSUserActivity Core Spotlight
| GitHub Issue | n/a | 
|---|---|
| Type | Improvement | 
| Priority | High | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2015-08-17T03:39:59.000+0000 | 
| Affected Version/s | n/a | 
| Fix Version/s | Release 5.0.0 | 
| Components | iOS | 
| Labels | IOS9, search, spotlight | 
| Reporter | Ben Bahrenburg | 
| Assignee | Eric Merriman | 
| Created | 2015-06-11T21:51:08.000+0000 | 
| Updated | 2017-03-21T18:36:21.000+0000 | 
Description
	Implement NSUserActivity to enable Core Spotlight access.
The following snippet from Apple shows this could be a straightforward Ti API.
// Create an attribute set that specifies a related unique ID for a Core Spotlight item.
CSSearchableItemAttributeSet *attributes = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:@"public.image"];
attributes.relatedUniqueIdentifier = coreSpotlightUniqueIdentifier;
// Use the attribute set to create an NSUserActivity that's related to a Core Spotlight item.
NSUserActivity *userActivity = [[NSUserActivity alloc]
 initWithActivityType:@“com.mycompany.viewing-message”];
userActivity.contentAttributeSet = attributes;
Ti.CoreSpotLight created with a proxy for SearchItem. Apple in the latest beta added a few additional methods which need to be refactored into the Ti.CoreSpotlight module methods
new doc reference: https://developer.apple.com/library/prerelease/ios/documentation/CoreSpotlight/Reference/CoreSpotlight_Framework/index.html#//apple_ref/doc/uid/TP40016250
PR added https://github.com/appcelerator/titanium_mobile/pull/7029 It is saying that the PR needs to be manually merged due to conflicts.
Closed Ben's PR in favour of https://github.com/appcelerator/titanium_mobile/pull/7034, which contains Ben's commits as well as some additional doc and code fixes.
CR and FT passed. PR merged.
PR here to fix *keyWord* to *keyword*. https://github.com/appcelerator/titanium_mobile/pull/7066 PR Merged.
I can get this to index most the time. Sometimes it crashes. Here is the info I have:
Here's the items I'm indexing:if (App.Device.versionMajor >= 9) { var searchItems = []; data.forEach(function (_row) { var itemAttr = Ti.App.iOS.createSearchableItemAttributeSet({ itemContentType: "public.content", title: _row.specie_name, contentDescription: "fishing regulation", keywords: [_row.specie_name] }); var item = Ti.App.iOS.createSearchableItem({ identifier: "fishrules_" + _row.specie_fish_id, domainIdentifier: "com.fishrulesapp.fishrules", attributeSet: itemAttr }); searchItems.push(item); }); var indexer = Ti.App.iOS.createSearchableIndex(); indexer.addToDefaultSearchableIndex(searchItems, function(e) {}); }PR here for missing imageData property and fix for URL: https://github.com/appcelerator/titanium_mobile/pull/7096 Approved and merged.
PR here to implement thread-safe methods which will solve Rick's issues: https://github.com/appcelerator/titanium_mobile/pull/7104 Approved and merged.
Closing ticket as fixed.