This is a light version of the godot share module for Godot Game Engine (2 & 3) for Android & iOS. You'll be able to share text and/or images in your apps.
-
Clone inside the "modules" directory on the Godot source.
-
Recompile android export template following the official instructions. In your project goto Export > Target > Android:
- Options:
- Custom Package:
- place your apk from build
- Custom Package:
- Options:
-
Add the following lines to
project.godot
file (Godot 3) orengine.cfg
(Godot 2):
[android]
modules="org/godotengine/godot/GodotShare"
If you have more separate by comma.
- Clone inside the "modules" directory on the Godot source;
- Recompile the iOS export template following the official instructions.
- For exporting, follow the exporting to iOS official documentation.
Just make sure you're using your custom template (compiled in the previous step), for that rename it to "godot_opt.iphone" and replace the file with same name inside the Xcode project.
- Export your project from Godot, it'll create an Xcode project;
- Copy the library (.a) you have compiled following the official documentation inside the exported Xcode project. You must override the 'your_project_name.a' file with this file.
The following methods are available:
# Share text
# @param String title
# @param String subject
# @param String text
shareText(title, subject, text)
# Share image
# @param String image_abs_path The image location absolute path
# @param String title
# @param String subject
# @param String text
void sharePic(image_abs_path, title, subject, text)
An important note is that the image you want to share must be saved on the "user://"
virtual directory root to be accessible, you can use OS.get_user_data_dir()
to get its absolute path (required by sharePic
).
In the demo directory you'll find a working sample project for Godot 2 and 3 where a screen capture is shared.
The screen capture isn't working for the Godot 3 project, it's a known issue for mobile platforms and you can see more details here.