Defold native extension to share application data using native sharing dialogs.
The extension currently supports OSX, iOS, Android and HTML5. Browser compatibility
You can use the Sharing extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:
https://github.com/britzl/defold-sharing/archive/master.zip
Or point to the ZIP file of a specific release.
Starting Defold 1.2.165 the Android dependencies are resolved using the build.gradle
file.
The share.* namespace will be nil if the share extension isn't supported (see System requirements above).
Share text using a native sharing dialog.
PARAMETERS
text
(string) - The text to share
Share an image (with optional text) using a native sharing dialog. Supported formats depend on the platform:
- Android - The image format must be supported by
BitmapFactory.decodeByteArray()
. On Android the image will first be stored locally as a file and then shared using a FileProvider. - iOS and macOS - The image format must be supported by
UIImage.initWithData
. - HTML5 - Either DataURI or any image format supported by the underlying platform.
PARAMETERS
bytes
(string) - The image bytes to sharetext
(string) - Optional text to sharefile_name
(string) - Optional Only forHTML5
image name. Default"file.png"
Share a file (with optional text) using a native sharing dialog. On Android the file will first be copied to a predefined location and then shared using a FileProvider. Files are shared with their original filename and extension. This will allow iOS to offer different kinds of applications depending on the shared content.
PARAMETERS
-
path
(string) - Full path to the file to share. ForHTML5
: specify the name of the file. Defaultfile.txt
. -
text
(string) - Optional text to share. ForHTML5
: specify the data that should be in the file. -
options
(table) - Optional Only forHTML5
.- type (string) - data type. Default
"text/plain"
- text (string) - text to be shared
- title (string) - title to be shared. May be ignored by the target
- url (string) - URL to be shared
- type (string) - data type. Default