Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19640] iOS9 Spotlight Search isSupported function doesn't work on pre-iOS9 devices

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionWon't Fix
Resolution Date2015-10-01T18:10:34.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.1.0
ComponentsiOS
Labelsios9, spotlight
ReporterCameron
AssigneeAngel Petkov
Created2015-09-22T22:06:24.000+0000
Updated2015-10-14T16:41:15.000+0000

Description

Im using .isSupported() to check if my iOS8.3 device should create indexs for Spotlight search. However, the isSupported call throws an error Code to test with (modified version from the Spotlight search sample app): // Create an instance of the index var searchableIndex = Ti.App.iOS.createSearchableIndex(); // Check if Spotlight is supported (since iOS 9) if (searchableIndex.isSupported()) { alert('You have iOS9 Spotlight Search'); } Error I am given when used on the actual device: "undefined is not an object (evaluating 't.isSupported')"

Comments

  1. Angel Petkov 2015-10-01

    Hello Im sorry your having issued with the platform , however unless you have both Xcode 7 and an iOS 9 device the searchableIndex will never get created. As previous iOS don't support the function, also is not part of the compile library for Xcode version prior to 7. The best approach to this problem would be to check the iOS version before initializing the variable .
      Example 
       if (Ti.Platform.version >= 9) {
       
       	Ti.API.info('iOS 9 supported');
       	// Create an instance of the index
       	var searchableIndex = Ti.App.iOS.createSearchableIndex();
       	// Check if Spotlight is supported (since iOS 9)
       	if (searchableIndex.isSupported()) {
       		alert('You have iOS9 Spotlight Search');
       	}
       	else 
       	{
       		//Do something
       		Ti.API.info('The device is not iOS 9 supported');
       	}
       }
       
       
  2. Cameron 2015-10-03

    Angel, Thats fine, I am manually checking the iOS version now, but what is the purpose of .isSupported() then ?
  3. Angel Petkov 2015-10-03

    The searchableIndex.isSupported() method just checks if your currently on Xcode 7, if you are it returns a message saying your device is supported.However unless you are on IOS 9 the object will never actually be created. I hope that helps.

JSON Source