NSUserActivity

suggest change

Introduction

An NSUserActivity object can be used to coordinate significant events in an app with the system. It is the basis for Handoff between different devices running iOS and macOS. Additionally, it may also be used to improve public-indexing and augment or create Spotlight Search results for an app. As of iOS 10, it may also be used to coordinate interactions between your app and Siri using SiriKit.

Remarks

Activity Types

Supported activity types must be defined in your app’s Info.plist file under the NSUserActivityTypes key. Activities are tied to your Developer Team ID, meaning that activity coordination is restricted between apps that have the same Team ID (e.g. “Safari” could not accept a Handoff activity from “Chrome” or vice versa).

Becoming / Resigning the Current Activity

Marking an activity as current using becomeCurrent makes it available for Handoff or Spotlight Indexing. Only one activity may be current at a time. You may mark an activity as inactive without invalidating by calling resignCurrent.

If you invalidate an activity, the same instance may not be made current again.

Do not mark an activity as current when providing it for SiriKit.

Search Indexing

Activities are not to be used as a general-purpose indexing mechanism within your app. Instead, they should only be used in response to user-initiated actions. To index all content in your app, use CoreSpotlight.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents