Share Action

Use this action in mobile applications to invoke the native sharing capabilities of the host platform and share content with other applications, such as Facebook, Twitter, Slack, SMS and so on.

The action module for this action is "vb/action/builtin/webShareAction".

Invoke this action following a user gesture, such as a button click. Also, we recommend that the share UI should only be shown if navigator.share is supported in the given browser, as in this HTML code:
<oj-button disabled="[[!navigator.share]]">Share</oj-button>
Parameter Name Description
title Optional. Represents the title of the document being shared. This value may be ignored by the target.
text Optional. Text that forms the body of the message being shared. Can be specified with or without a URL.
url Optional. URL string that refers to the resource being shared. Any URL can be shared, not just URLs under website's current scope.

Although all parameters are individually optional, you must specify at least one parameter.

Example:

"share": {
  "module": "vb/action/builtin/webShareAction",
  "parameters": {
    "text": "Check out this cool new app!",
    "title": "[[document.querySelector('h1').textContent]]",
    "url": "[[ document.querySelector('link[rel=canonical]') && document.querySelector('link[rel=canonical]').href || window.location.href]]",
  },
  "outcomes": {
    "failure": "handleShareError"
  }
}

A success outcome is returned when the user completes a share action. A failure outcome is returned when the browser does not support the Web Share API or a parameter error is detected.