init(activityType : String)
init()
Availability 有効性
Technology
class NSUserActivity : NSObject
An NSUser
object provides a lightweight way to capture the state of your app and put it to use later.
NSUser
オブジェクトは、あなたのアプリの状態をキャプチャ(捕獲、記録)して、それを後で使うようにする軽量な方法を提供します。
Create this object to capture information about what the user was doing, such as viewing app content, editing a document, viewing a web page, or watching a video. When the system launches your app and an activity object is available, your app can use the information in that object to restore itself to an appropriate state.
システムがあなたのアプリを起動するそしてアクティビティオブジェクトが利用可能になる時、あなたのアプリは、そのオブジェクトの中の情報を使ってそれ自身を適切な状態へと復元できます。
Spotlight also uses these objects to improve search results for the user. To allow users to continue an activity on another device, see Implementing Handoff in Your App.
If SiriKit needs to launch your app for any reason, it creates a user activity object and assigns an appropriate INInteraction
object to its interaction
property. Your app can use the interaction information to configure itself and display information related to the interaction started by SiriKit. You can also provide SiriKit with a custom user activity object containing additional data that you want passed to your app.
SiriKitがあなたのアプリを何らかの理由のために起動する必要があるならば、それはユーザアクティビティオブジェクトを作成して、適切なINInteraction
オブジェクトをそれのinteraction
プロパティへと代入します。あなたのアプリは、その相互作用情報を使って自身を構成設定します、そしてSiriKitによって開始された相互作用に関連して情報を表示します。あなたはまたSiriKitに、あなたがあなたのアプリに渡されることを望む追加データを含んでいる、あつらえのユーザアクティビティオブジェクトを提供できます。
In iOS 15 and later, the user can share content they’re viewing by asking Siri to “share this”. Apps built with Mac Catalyst provide the same capability with an NSSharing
in the toolbar. You can use activity
or activity
to provide shareable content. In iOS, if both of those properties are nil
, Siri uses the webpage
property of your app’s current user activity as a fallback value.
Quick Note on macOS and iOS can link to any app content represented as an NSUser
. To appear as a link, the content must be the app’s current activity, and provide at least one of the following identifiers:
webpageURL
An https:
URL, ideally in a canonical form that’s consistent every time the user visits the same content.
persistentIdentifier
A string that uniquely identifies the content in this domain. The identifier should identify the same content across devices.
targetContentIdentifier
A string that uniquely identifies the content in this domain, but also allows disambiguating between multiple scenes of an app. The identifier should identify the same content across devices.
To work well with Quick Note, content must adhere to the following guidelines:
The activity title
should be clear and concise. This text describes the content of the link, like “Photo taken on July 27, 2020” or “Conversation with Maria”. Use nouns for activity titles.
Keep the app’s current activity up to date, using become
and resign
.
Linkable identifiers (listed above) must be stable and consistent for the same content. When you link from a note to a document in an app, and later revisit that document, the system shows an indicator linking back to the note. The system compares identifiers to check that the document is the same as the original source of the link.
Maintain support for activities provided by your app, and support navigating to linked content indefinitely. Links added to notes are important to the user, who may feel that a broken link indicates data loss.
Gracefully handle attempts to navigate to an activity that points to content that doesn’t exist. For example, you can redirect to the new location of moved content, or show an error message. This situation may happen with shared notes, when a user links to content that exists only on another user’s device.
If your NSUser
objects contain information that the user might want to search for later, set the is
property to true
. When you enable search, Spotlight indexes your user activity objects and considers them during subsequent on-device searches. For example, if the user viewed information about a particular restaurant in your app, you would enable search for the corresponding user activity object. Subsequent searches for restaurants using Spotlight could then include the results obtained from your user activity object.
あなたのNSUser
オブジェクトが、ユーザが後で検索したいかもしれない情報を含むならば、is
プロパティをtrue
に設定してください。あなたが検索を可能にする場合、Spotlightはあなたのユーザアクティビティオブジェクトの索引作成をして、それらを以降のデバイス上の検索の間を通して考慮に入れます。例えば、ユーザがある特定のレストランについての情報をあなたのアプリにおいて閲覧したならば、あなたはその対応するユーザアクティビティオブジェクトに対して検索を可能にするでしょう。Spotlightを使ってのレストランについての以降の検索は、あなたのユーザアクティビティオブジェクトから入手された結果をそのとき含むことができます。
In addition to on-device searches, you can contribute URLs accessed by your app with the global Spotlight search engine. Sharing a URL helps Spotlight improve its own search results for other users. To contribute a URL, put the URL in the webpage
property of your activity object and set the is
property to true
.
デバイス上の検索に加えて、あなたは、あなたのアプリによってグローバルSpotlight検索エンジンをつかってアクセスされたURLを提供できます。URLの共有は、他のユーザに対してSpotlightが自身の検索結果を向上させる助けとなります。URLを提供するには、そのURLをあなたのアクティビティオブジェクトのwebpage
プロパティの中に入れてください、そしてis
プロパティをtrue
に設定してください。
Important 重要
Your app must maintain a strong reference to any activity objects that you use for search results. あなたのアプリは、あなたが検索結果のために使うあらゆるアクティビティオブジェクトに対する強い参照を保守しなければなりません。
Employ user activity objects to record user-initiated activities, not as a general-purpose indexing mechanism of your app's data. ユーザアクティビティオブジェクトをユーザ着手アクティビティの記録に従事させてください、あなたのアプリのもつデータの一般的目的のインデックス作成機構としてでなく。 To index all of your app’s content, and not just the content touched by the user, use the APIs of the Core Spotlight framework.
init(activityType : String)
init()
var activityType : String
var title: String?
var requiredUserInfoKeys : Set<String>?
var userInfo : [AnyHashable : Any]?
func addUserInfoEntries (from: [AnyHashable : Any])
var targetContentIdentifier : String?
var needsSave : Bool
var contentAttributeSet : CSSearchableItemAttributeSet?
var keywords: Set<String>
var persistentIdentifier : NSUserActivityPersistentIdentifier?
typealias NSUserActivityPersistentIdentifier
var appClipActivationPayload : APActivationPayload?
var isEligibleForHandoff : Bool
var isEligibleForSearch : Bool
var isEligibleForPublicIndexing : Bool
var expirationDate : Date?
func becomeCurrent ()
func resignCurrent ()
func invalidate()
class func deleteAllSavedUserActivities (completionHandler : () -> Void)
class func deleteSavedUserActivities (withPersistentIdentifiers : [NSUserActivityPersistentIdentifier], completionHandler : () -> Void)
var delegate: NSUserActivityDelegate?
protocol NSUserActivityDelegate
var supportsContinuationStreams : Bool
func getContinuationStreams (completionHandler : (InputStream?, OutputStream?, Error?) -> Void)
var webpageURL : URL?
var referrerURL : URL?
var isEligibleForPrediction : Bool
var suggestedInvocationPhrase : String?
var shortcutAvailability : INShortcutAvailabilityOptions
var interaction: INInteraction?
var ndefMessagePayload : NFCNDEFMessage
var detectedBarcodeDescriptor : CIBarcodeDescriptor?
var mapItem : MKMapItem!
var externalMediaContentIdentifier : String?
func setTypedPayload <T>(T)
func typedPayload <T>(T.Type) -> T
enum NSUserActivity.TypedPayloadError
var isClassKitDeepLink : Bool
var contextIdentifierPath : [String]?
let NSUserActivityTypeBrowsingWeb : String
let TVUserActivityTypeBrowsingChannelGuide : String
var NSUserActivityConnectionUnavailableError : Int
var NSUserActivityErrorMaximum : Int
var NSUserActivityErrorMinimum : Int
var NSUserActivityHandoffFailedError : Int
var NSUserActivityHandoffUserInfoTooLargeError : Int
var NSUserActivityRemoteApplicationTimedOutError : Int
protocol NSUserActivityDelegate