📲
PWA Bundle
1.0.x
1.0.x
  • PHPWA Bundle
  • How To Create A PWA?
  • How To Install/Remove A PWA?
  • Bundle Installation
  • Deployment
  • The Manifest
    • Application Information
      • Scope
      • ID
      • Direction and Language
      • Orientation
      • Description
      • IARC Rating ID
      • Categories
    • Icons
    • Screenshots
    • Shortcuts
    • Protocol Handlers
    • File Handlers
    • Share Target
    • Complete Example
  • The Service Worker
    • Configuration
    • Content Security Policy
    • Custom Service Worker Rule
    • Workbox
      • Site Manifest Cache
      • Asset Caching
      • Resource Caching
      • Image Caching
      • Font Caching
      • Offline Fallbacks
      • BackgoundSync
      • CDN and Versions
      • Cache Cleaning
      • Custom Cache Strategy
    • Push Notifications
    • Complete Example
  • Symfony UX
    • Connection Status
    • Prefetch on demand
    • Sync Broadcast
    • BackgroundSync Form
  • Image Management
    • Icons
    • Screenshots
  • Experimental Features
    • Non-Standard Parameters
      • Launch Handler
      • Display Override
      • Related Applications
      • EDGE Side Panel
    • Translations
    • Widgets (Win10+)
Powered by GitBook
On this page
  • action Parameter
  • method Parameter
  • enctype Parameter
  • params Parameter

Was this helpful?

Edit on GitHub
Export as PDF
  1. The Manifest

Share Target

PreviousFile HandlersNextComplete Example

Last updated 1 year ago

Was this helpful?

The Share Target feature enhances the functionality of Progressive Web Apps (PWAs) by seamlessly integrating them into the native operating system's sharing capabilities. This means that when users come across content that they want to share from any app or browser, your PWA can appear in the list of sharing options alongside other native applications.

In the example below, the PWA indicates it can receive image files. The files are sent to the application using a POST request to /share-target and multipart/form-data encoding. The shared file is in the request body file member.

/config/packages/pwa.yaml
pwa:
    manifest:
        enabled: true
            share_target:
              action: "/share-target"
              method: "POST"
              enctype: "multipart/form-data"
              params:
                  files:
                      - name: "file",
                        accept: ["image/*"]

The POST request is ideally replied with an HTTP 303 See Other redirect to avoid multiple POST requests from being submitted if a page refresh was initiated by the user, for example.

action Parameter

The URL of the share target. See the for the details.

method Parameter

The HTTP request method to use. Either GET or POST.

Use POST if the shared data includes binary data like image(s), or if it changes the target app, for example, if it creates a data point like a bookmark.

enctype Parameter

The encoding of the share data when a POST request is used. Ignored with GET requests.

params Parameter

An object to configure the share parameters.

Object values can be specified and will be used as query parameters. Unless otherwise noted, members are optional.

  • title: Name of the query parameter to use for the title of the document being shared.

  • text: Name of the query parameter for the text (or body) of the message being shared.

  • url : Name of the query parameter for the URL to the resource being shared.

  • files: a list defining which files are accepted by the share target. Each item requires the following properties:

    • name: Name of the form field used to share files.

    • accept : a list of accepted MIME types or file extensions.

URL parameter