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.
| Property | Description |
|---|---|
activityType read-only | Where the user chose to share |
completed read-only | Whether the chosen action was carried out |
activityError read-only | The 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
| Object | Events |
|---|---|
UIActivityViewController | complete |
It can't be canceled: cancelable is false, and preventDefault() has no effect.
Examples
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.
| ObjC | JS |
|---|---|
activityType | event.activityType |
completed | event.completed |
activityError | event.activityError |
See also
UIActivityViewController: the object that fires this eventcomplete: when it is fired