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- Pick a release from britzl/defold-sharing releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as share from "share"
- Pick a release from britzl/defold-sharing releases and add its Source code (zip) URL (or a packaged
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 isfile.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 isfile.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.