Sunday, January 31, 2016

iOS Search Using NSUserActivity

In addition to support handoff, using NSUserActivity will allow in iOS 9.0 and later below items 

1. Index activities as users perform them in the app. Activities could be creating or viewing content, viewing a set of items (such as result list) or visiting navigation point within the app 
2. Mark specific items available for public searching 
3. provide indexable meta data about an item which gives user rich information in search results 

To provide best search results, one should avoid creating multiple NSUserActvities objects at one time. Also, NSUSerActivity is not intended for App specific arbitrary data. For indexing App content, need to use the core spot light framework. Also can use the relatedUniqueIdentifier to link the items together 

Using NSUSerActivity also lets one to take advantage of Siri suggestions and smart reminders. Siri suggestions are displayed in the core spotlight search screen and can incldue searchable activities. Users can use smart reminders to be reminded about specific content related to the app. When users receive a smart reminder, the activity they specified is displayed in the reminder. 

As the user uses the app, we can create activity objects associated with various navigation points and app states. Each item is added to the on-device index by default. In iOS 9.0 Making a public item as eligible for public indexing also adds it to on-device index and confers to additional advantage: When we use web markup to make the related content searchable, user engagement with publicly eligible search results from the app can help improve the ranking of website content 

to make an activity or navigation point searchable, create an NSUserActivity object to represent it, Use NSUserActivity to represent it. it is like below 

var activity: NSUserActivity = NSUserActivity(activityType:”com.mycompany.myContentType”);
activity.title = “My Activity Title”
activity.userInfo = [“id”,”http://www.google.com”]
activity.eligibleForSearch = true;


References:

No comments:

Post a Comment