Member-only story
NSUserActivity in iOS
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.
Creating a NSUserActivity
To create a NSUserActivity object, your app must declare the types of activities it supports in its Info.plist file. Supported activities are defined by your application and should be unique. An activity is defined using a reverse- domain style naming scheme (i.e. “com.companyName.productName.activityName”). Here is what an entry in your Info.plist might look like:
Once you have defined all supported activity types, you may begin to access and use them in your application’s code.
To create a NSUserActivity object you must do the following
// Initialize the activity object and set its type from one of the ones specified in your app's
plist
NSUserActivity *currentActivity = [[NSUserActivity alloc]
initWithActivityType:@"com.companyName.productName.activityName01"];// Set the title of the activity.
// This title may be displayed to the user, so make sure it is localized and human-readable…