Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19006] iOS9: Implement NSUserActivity Core Spotlight

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-08-17T03:39:59.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.0.0
ComponentsiOS
LabelsIOS9, search, spotlight
ReporterBen Bahrenburg
AssigneeEric Merriman
Created2015-06-11T21:51:08.000+0000
Updated2017-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;

Comments

  1. Ben Bahrenburg 2015-07-02

    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
  2. Chee Kiat Ng 2015-07-24

    new doc reference: https://developer.apple.com/library/prerelease/ios/documentation/CoreSpotlight/Reference/CoreSpotlight_Framework/index.html#//apple_ref/doc/uid/TP40016250
  3. Ben Bahrenburg 2015-08-16

    PR added https://github.com/appcelerator/titanium_mobile/pull/7029 It is saying that the PR needs to be manually merged due to conflicts.
  4. Chee Kiat Ng 2015-08-17

    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.
  5. Chee Kiat Ng 2015-08-17

    CR and FT passed. PR merged.
  6. Chee Kiat Ng 2015-08-25

    PR here to fix *keyWord* to *keyword*. https://github.com/appcelerator/titanium_mobile/pull/7066 PR Merged.
  7. Rick Blalock 2015-08-28

    I can get this to index most the time. Sometimes it crashes. Here is the info I have:
       [TRACE] [Fish Rules App] 1   0x10af8714b TiBindingEventProcess
       [TRACE] [Fish Rules App] 2   0x10af87598 -[TiBindingCallbackInvoke invoke:]
       [TRACE] [Fish Rules App] 3   0x10ad53bef -[KrollContext invoke:]
       [TRACE] [Fish Rules App] 4   0x10ad53caa __24-[KrollContext enqueue:]_block_invoke
       [TRACE] [Fish Rules App] 5   0x1143caea9 _dispatch_call_block_and_release
       [TRACE] [Fish Rules App] 6   0x1143e64c7 _dispatch_client_callout
       [TRACE] [Fish Rules App] 7   0x1143d107d _dispatch_main_queue_callback_4CF
       [TRACE] [Fish Rules App] 8   0x110872e69 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
       [TRACE] [Fish Rules App] 9   0x1108343b9 __CFRunLoopRun
       [TRACE] [Fish Rules App] 10  0x110833918 CFRunLoopRunSpecific
       [TRACE] [Fish Rules App] 11  0x1115d1ad2 GSEventRunModal
       [TRACE] [Fish Rules App] 12  0x10d21b99e UIApplicationMain
       [TRACE] [Fish Rules App] 13  0x10ad35d26 main
       [TRACE] [Fish Rules App] 14  0x11441692d start
       
       Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
       0   com.fishrulesapp.fishrules    	0x000000010b2f3b0e Ti_WTFCrash + 62
       1   com.fishrulesapp.fishrules    	0x000000010b16b7ed TiObjectSetProperty + 685
       2   com.fishrulesapp.fishrules    	0x000000010af8714b TiBindingEventProcess + 539
       3   com.fishrulesapp.fishrules    	0x000000010af87598 -[TiBindingCallbackInvoke invoke:] + 56
       4   com.fishrulesapp.fishrules    	0x000000010ad53bef -[KrollContext invoke:] + 159
       5   com.fishrulesapp.fishrules    	0x000000010ad53caa __24-[KrollContext enqueue:]_block_invoke + 42
       6   libdispatch.dylib             	0x00000001143caea9 _dispatch_call_block_and_release + 12
       7   libdispatch.dylib             	0x00000001143e64c7 _dispatch_client_callout + 8
       8   libdispatch.dylib             	0x00000001143d107d _dispatch_main_queue_callback_4CF + 714
       9   com.apple.CoreFoundation      	0x0000000110872e69 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
       10  com.apple.CoreFoundation      	0x00000001108343b9 __CFRunLoopRun + 2073
       11  com.apple.CoreFoundation      	0x0000000110833918 CFRunLoopRunSpecific + 488
       12  com.apple.GraphicsServices    	0x00000001115d1ad2 GSEventRunModal + 161
       13  com.apple.UIKit               	0x000000010d21b99e UIApplicationMain + 171
       14  com.fishrulesapp.fishrules    	0x000000010ad35d26 main + 310
       15  libdyld.dylib                 	0x000000011441692d start + 1
       
    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) {});
       		}
       
  8. Chee Kiat Ng 2015-08-31

    PR here for missing imageData property and fix for URL: https://github.com/appcelerator/titanium_mobile/pull/7096 Approved and merged.
  9. Chee Kiat Ng 2015-09-01

    PR here to implement thread-safe methods which will solve Rick's issues: https://github.com/appcelerator/titanium_mobile/pull/7104 Approved and merged.
  10. Lee Morris 2017-03-21

    Closing ticket as fixed.

JSON Source