onContinueUserActivity

Registers a handler to invoke in response to a user activity that your app receives.

View ModifieriOS 14.0+macOS 11.0+tvOS 14.0+watchOS 7.0+onContinueUserActivity(_:perform:) in SwiftUI

Declaration

React
compose().onContinueUserActivity(
  activityType: string,
  options: {
    perform: (arg0: { activityType?: string; title?: string; webpageURL?: string; userInfo?: Record<string, unknown>; isEligibleForHandoff?: boolean; isEligibleForSearch?: boolean; isEligibleForPrediction?: boolean; }) => void;
  }
)
Swift
nonisolated func onContinueUserActivity(
    _ activityType: String,
    perform action: @escaping (NSUserActivity) -> ()
) -> some View

Parameters

  • activityType*string

    The type of activity that the action closure handles. Be sure that this string matches one of the values that you list in the doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSUserActivityTypes array in your app's Information Property List.

  • options.perform*(arg0: { activityType?: string; title?: string; webpageURL?: string; userInfo?: Record<string, unknown>; isEligibleForHandoff?: boolean; isEligibleForSearch?: boolean; isEligibleForPrediction?: boolean; }) => void

Return value

A view that handles incoming user activities.

Discussion

Use this view modifier to receive doc://com.apple.documentation/documentation/Foundation/NSUserActivity instances in a particular scene within your app. The scene that SwiftUI routes the incoming user activity to depends on the structure of your app, what scenes are active, and other configuration. For more information, see Scene.handlesExternalEvents(matching:).

UI frameworks traditionally pass Universal Links to your app using a user activity. However, SwiftUI passes a Universal Link to your app directly as a URL. To receive a Universal Link, use the View.onOpenURL(perform:) modifier instead.

See also

More in Events and lifecycle.