Skip to content

UIActivityViewControllerCompletionEvent ​

UIActivityViewControllerCompletionEvent represents the system share sheet finishing, with what the user chose and whether it was done.

The complete event of UIActivityViewController is this class.

Inheritance: Event → UIActivityViewControllerCompletionEvent

Constructor ​

UIActivityViewControllerCompletionEvent()

Creates a UIActivityViewControllerCompletionEvent. The runtime creates one itself when it fires the events below; app code can use it to build an event object and fire it with dispatchEvent() to try out a listener.

Instance properties ​

Also inherits the properties of Event; the most commonly used are type and target. The properties below are read-only; assigning to them throws TypeError.

PropertyDescription
activityType read-onlyWhere the user chose to share
completed read-onlyWhether the chosen action was carried out
activityError read-onlyThe error the system gave when the action failed

These properties live on the prototype, not on the event object itself: Object.keys(event) and { ...event } don't include them, so read them one by one. See Events with fields.

Events that use this class ​

ObjectEvents
UIActivityViewControllercomplete

It can't be canceled: cancelable is false, and preventDefault() has no effect.

Examples ​

js
const sheet = new UIActivityViewController([new URL('https://example.com')]);
sheet.addEventListener('complete', (e) => {
  console.log(e instanceof UIActivityViewControllerCompletionEvent, e.completed, e.activityType);
});

Effect: when the sheet finishes, prints true, whether the action was done, and where the user chose to share.

Corresponding iOS API ​

Of the four parameters of UIActivityViewController.completionWithItemsHandler, three are fields of the same names on the event object.

ObjCJS
activityTypeevent.activityType
completedevent.completed
activityErrorevent.activityError

See also ​