-2

Can anybody please provide me tutorial or example code in NSUserActivity feature for SearchApi. I am doing lots of RND about this feature but didn't get proper code for this.

bytecode77
  • 14,163
  • 30
  • 110
  • 141
Abha
  • 1,032
  • 1
  • 13
  • 36
  • https://developer.apple.com/documentation/foundation/task_management/continuing_user_activities_with_handoff – Curiosity Jun 19 '21 at 00:25

1 Answers1

2

An example would be:

let activity = NSUserActivity(activityType: "com.tutsplus.iOS-9-Search.displayShow")
activity.userInfo = ["name": detailItem.name, "genre": detailItem.genre, "time": detailItem.time]
activity.title = detailItem.name
var keywords = detailItem.name.componentsSeparatedByString(" ")
keywords.append(detailItem.genre)
activity.keywords = Set(keywords)
activity.eligibleForHandoff = false
activity.eligibleForSearch = true
//activity.eligibleForPublicIndexing = true
//activity.expirationDate = NSDate()

activity.becomeCurrent()

See this link for more information and examples

Roland Keesom
  • 8,180
  • 5
  • 45
  • 52