17 Replies
      Latest reply on Sep 17, 2015 11:55 AM by pdm
      matttancock Level 1 Level 1 (10 points)

        I take it back, I've got NSUserActivity indexing to work on b3.

         

        I've narrowed the issue down to the following:

         

        If i set a relatedUniqueIdentifier (to anything) in a CSSearchableItemAttributeSet which is assigned to the NSUserActivity, the item doesn't get indexed.

         

        If I leave the item without a uniqueID, it gets indexed.

         

        This however poses a problem in regards to the whole de-duplication thing!

         

        If I have time tomorrow I'll post a radar. Anyone else have this issue? Just me?

        • Re: relatedUniqueIdentifier issue
          pdm Apple Staff Apple Staff (1,770 points)

          Please get a bug report filed ASAP with a sample project attached. 

            • Re: relatedUniqueIdentifier issue
              matttancock Level 1 Level 1 (10 points)

              Bug filed as 21871508 with sample project.

               

              Thanks!

                • Re: relatedUniqueIdentifier issue
                  pdm Apple Staff Apple Staff (1,770 points)

                  That's super helpful, we'll take a look at it!

                    • Re: relatedUniqueIdentifier issue
                      matttancock Level 1 Level 1 (10 points)

                      My bug was closed as "works as expected". So that means I either didn't explain myself very well, or I don't understand relatedUniqueIdentifier.

                       

                      I was under the impression that relatedUniqueIdentifier could be used to that in the event the same content is added to the index either via Core Spotlight or via the AppleBot that it would enable de-duplication: See iOS 9.0 release notes:

                       

                      When you combine multiple Search APIs, items can get indexed from multiple places. To avoid giving users duplicate items in search results, you need to link item IDs appropriately. To ensure that item IDs are linked, you can use the same value in a searchable item’s uniqueIdentifier property and in the relatedUniqueIdentifier property within an NSUserActivity object’s contentAttributes property. If you use all three APIs, it works well to use a specific URL as the value that uniquely identifies an item. (You can also set an NSUserActivity object’s webpageURL property to the URL for an item.)

                       

                      So how am I supposed to do that if I can't use the relatedUniqueIdentifier property when trying to index an NSUserActivity?

                        • Re: relatedUniqueIdentifier issue
                          jsalaber Level 1 Level 1 (0 points)

                          I too am having this problem. Populating the relatedUniqueIdentifier field to anything will prevent me from indexing. I want to be able to delete the activity.

                          • Re: relatedUniqueIdentifier issue
                            ortwin Level 1 Level 1 (0 points)

                            Don't understand why matttancock's bug was closed.

                            I'm also affected by this and I've logged radar 21958439 (also on Open Radar).

                              • Re: relatedUniqueIdentifier issue
                                matttancock Level 1 Level 1 (10 points)

                                The only thing I can guess (as I didn't get any clarification on my closed radar as I requested) is that somewhere there's an assumption that relatedUniqueIdentifier will only be used when you're associating a userActivity with an already indexed Core Spotlight item. And therefore the NSUserActivity doesn't need indexing, but is just more of a +1.

                                 

                                Unfortunately this assumption is either faulty or just severely limiting depending on the possible circumstances:

                                 

                                1) What if we don't know which will get indexed first. (We potentially have some control over this, but it's still potentially limiting)

                                2) What if we're trying to associated an NSUserActivity with an item which is _potentially_ indexed by the web indexer? (We have no control over when/if the item will be indexed by the AppleBot)

                                 

                                I've asked more than once, but how are we supposed to relate those indexing activities if we can't use relatedUniqueIdentifier?

                            • Re: relatedUniqueIdentifier issue
                              matttancock Level 1 Level 1 (10 points)

                              Still waiting for clarification on this. Thanks

                                • Re: relatedUniqueIdentifier issue
                                  SHProgrammer Level 1 Level 1 (0 points)

                                  I would also like an answer to this too.

                                   

                                  For my situation, I want to add an user activity when the user visits a page.  I also want to add a searchable item when the user marks the page and delete the item when the user unmarks the page.  If the user activity is added before user marks the page (so before the related searchable item is added), then the user activity doesn't seem to be indexed.

                                   

                                  Thanks.

                          • Re: relatedUniqueIdentifier issue
                            myrddin Level 1 Level 1 (0 points)

                            I have the same issue...

                            When I set a value for this attribute, the activity is not indexed.

                            So, what's the solution to index only once time the activity without unique identifier ?

                              • Re: relatedUniqueIdentifier issue
                                pdm Apple Staff Apple Staff (1,770 points)

                                You need to add the item to the index first.  You should be able to simply add it to the index with the unique identifier, even with minimal information, and then you could (if necessary) update it later.  If you're setting the relatedUniqueIdentifier, then that identifier needs to be in the index. 

                                  • Re: relatedUniqueIdentifier issue
                                    Benjamin33 Level 1 Level 1 (0 points)

                                    Hi,

                                    Could you please clarify that when using CoreSpotlight in combination with NSUserActivities that have public indexing enabled. When the user taps the search result does the search item (NSUserActivity) still get sent for public indexing?

                                     

                                    Thanks

                                      • Re: relatedUniqueIdentifier issue
                                        pdm Apple Staff Apple Staff (1,770 points)

                                        This sounds like an unrelated question to this thread.  I'd prefer if you could create a new topic to track this question (so that people can find it in the forums instead of it being buried in a thread with a completely different title). 

                                      • Re: relatedUniqueIdentifier issue
                                        aprato Level 1 Level 1 (10 points)

                                        Currently I'm only indexing user content (in my case things they favorite) so I have the same problem with NSUserActivity when a user views something that isn't one of their favorites. I was setting relatedUniqueIdentifier to the web URL to link up with out web markup. Is this not correct? Or to pair up with our web content do I need to add all activity to the local index whenever I create/update a user activity?

                                          • Re: relatedUniqueIdentifier issue
                                            pdm Apple Staff Apple Staff (1,770 points)

                                            To pair a NSUserActivity up to web content you'd set the webpageURL. But if you're indexing user content then you definitely want to use CoreSpotlight to put that in the index.  Then NSUserActivity would be used when the user actually viewed or interacted with that content in your app.  In that case you'd want to set the webpageURL to match your web content and the relatedUniqueIdentifier to match your (already inserted) CoreSpotlight entries. 

                                          • Re: relatedUniqueIdentifier issue
                                            axaiOS Level 1 Level 1 (0 points)

                                            How does this help if your are only using the NSUserActivty and not Core Spotlight. I am getting duplicate results as well. I tried adding the activity and the updating it using updateUserActivityState: but if I add the relatedUniqueIdentifier is does not get indexed at all.

                                              • Re: relatedUniqueIdentifier issue
                                                pdm Apple Staff Apple Staff (1,770 points)

                                                If you're not using CoreSpotlight then there's no reason to be setting a relatedUniqueIdentifier.  That property is only for linking an NSUserActivity to a CoreSpotlight item.  If you're only using NSUserActivity and web markup, then set the webpageURL on the NSUserActivity to the page that it corresponds to.