title: Duplicated display of NSUserActivity in Spotlight
body: <p>I know there are several <a href="https://stackoverflow.com/questions/32134733/usage-of-nsuseractivity-and-corespotlight">posts</a> on this topic out there but they differed to much from my problem. </p>
  
  <p>I am trying to display my <code>NSUserActivity</code> in Spotlight Search. For my <code>NSUserActivity</code> I am using three APIs: <code>.isEligibleForHandoff</code>, <code>.isEligibleForSearch</code> and <code>.isEligibleForPrediction</code>.</p>
  
  <p>My problem is that my activity is being displayed twice in the Spotlight Search and that one of the results delivers an empty userInfo and the other one doesn't. However the <a href="https://stackoverflow.com/questions/34732192/duplicate-search-results-in-spotlight">Apple Programming Guide</a> suggests:</p>
  
  <blockquote>
    <p>Use the following strategies to avoid creating duplicate
    representations of a single item:</p>
    
    <p>If you’re using both NSUserActivity and Core Spotlight APIs to index
    an item, use the same value for relatedUniqueIdentifier and
    uniqueIdentifier to link the representations of the item.</p>
  </blockquote>
  
  <p>But I don't think this is even my problem since I am not using any Core Spotlight APIs.</p>
  
  <p>Thats my code inside my <code>UIResponder</code> class:</p>
  
  <pre><code>let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeItem as String)
  attributeSet.title = "Place Order Search"
  attributeSet.contentDescription = "Get Your Avocado Toast Now"
  attributeSet.relatedUniqueIdentifier = ActivityType.placeOrder.rawValue
  
  let avocadoToastDictionary = AvocadoToastManger.dictionary(from: avocadoToastOrder)
  let jsonAvocadoToastData = json(from: avocadoToastDictionary)
  let activity = NSUserActivity(activityType: ActivityType.placeOrder.rawValue)
  activity.title = "Place Order"
  activity.userInfo = ["PlaceOrder.avocadoToast": jsonAvocadoToastData]
  activity.requiredUserInfoKeys = ["PlaceOrder.avocadoToast"]
  activity.suggestedInvocationPhrase = "Order an Avocado Toast"
  activity.keywords = ["Order", "Avocado Toast"]
  activity.isEligibleForHandoff = true
  activity.isEligibleForSearch = true
  activity.isEligibleForPrediction = true
  activity.contentAttributeSet = attributeSet
  
  self.userActivity = activity
  activity.becomeCurrent()
  </code></pre>
  
  <p>Note: The <code>updateUserActivityState(activity:)</code> method is getting called twice in a row.</p>
  
  <p>So how can I void getting multiple search results in the Spotlight Search and make sure the one which has the <code>userInfo</code> property set stays. </p>