Share

The Share action is used to invoke the native sharing capabilities of the host platform in order to share content with other applications, such as Facebook, Twitter, Slack, SMS and so on.

Invoke this action following a user gesture, such as a button click. Also, we recommend that the Share action's UI only be shown if navigator.share is supported by the given browser, as in this HTML code:
<oj-button disabled="[[!navigator.share]]">Share</oj-button>

This table describes the parameters for the Share action:

Parameter Name Description
title Represents the title of the document being shared. This value may be ignored by the target.
text Text that forms the body of the message being shared. Can be specified with or without a URL.
url URL string that refers to the resource being shared. Any URL can be shared, not just URLs under website's current scope.

Here's an example of a call to the Share action:

     await Actions.webShare(context, {
        title: document.querySelector('h1').textContent,
        text: 'Check out this cool new app!',
        url: document.querySelector('link[rel=canonical]') && document.querySelector('link[rel=canonical]').href || window.location.href,
     });