Skip to Content
defold-typescript libraries
britzl

britzl/defold-sharing/share

Defold native extension to share data from a Defold application using native dialogs

  • GitHub: britzl/defold-sharing — pinned to 4.7.0
    1. Pick a release from britzl/defold-sharing releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as share from "share"

Functions

text(text: string)

Share text using a native sharing dialog.

Parameters

  • text: string — The text to share.

image(bytes: string, text?: string, file_name?: string)

Share an image, with optional text, using a native sharing dialog. On Android the image must be decodable by BitmapFactory.decodeByteArray(), on iOS and macOS by UIImage.initWithData, and on HTML5 it may be a data URI or any format the browser supports.

Parameters

  • bytes: string — The image bytes to share.
  • text?: string — Optional text to share.
  • file_name?: string — Image file name, HTML5 only. Default is file.png.

file(path: string, text?: string, options?: FileOptions)

Share a file, with optional text, using a native sharing dialog. The file keeps its original name and extension.

Parameters

  • path: string — Full path to the file to share. On HTML5, the file name. Default is file.txt.
  • text?: string — Optional text to share. On HTML5, the contents of the file.
  • options?: FileOptions — Extra share details, HTML5 only.

Types

FileOptions

FileOptions.type?: string

Data type. Default is text/plain.

FileOptions.text?: string

Text to be shared.

FileOptions.title?: string

Title to be shared. May be ignored by the target.

FileOptions.url?: string

URL to be shared.

On this page