Shares a text. Optionally, an URL and a title can be added (otherwise, leave them empty).
It allows sharing an Image. Optionally, a text, an URL and a title can be attached to it.
It allows sharing a File (e.g. a PDF file generated by the application). Optionally, a text, and a title can be provided.
Note: in iOS the text parameter is ignored.
This method is available as of GeneXus 17 upgrade 7.
It does not have any
In LightCRM, suppose we want users to share information about the meeting.
To do this, we add a “Share” button to the Application Bar of the Work with Meeting object.
Next, we program the Event associated with this button.
Event 'Share'
Composite
If not CompanyLogo.IsEmpty()
msg("Sharing meeting with image",status)
Share.ShareImage(CompanyLogo, MeetingTitle,!"http://www.genexus.com",MeetingNote)
Else
msg("Sharing meeting",status)
Share.ShareText(MeetingTitle,!"http://www.genexus.com",MeetingNote)
EndIf
EndComposite
EndEvent
The application will look as shown below. Clicking on the button displays a pop-up dialog that shows the applications installed on our device for sharing content. Lastly, you must to select one of these applications and share it!
Supsose that you have an offline application that generates a PDF file, and you want to give your users the possibility of exporting that file to save it to a cloud storage provider, like Dropbox, Google Drive, or iCloud.
You coud then have a GeneratePDF Procedure with the following rules
parm(in:&fileName, out:&fileUrl);
output_file(&fileName, "PDF");
and this code somewhere in the source part:
&filePath = Directory.TemporaryFilesPath + &file.Separator + &name + '.' + &extension
&fileUrl = !'file://' + &filePath
To share the generated PDF file from an action in your application, you could add a button with the following associated event:
Event 'ShareFile'
composite
&fileUrl = GeneratePDF('Sample')
GeneXus.Social.Share.ShareFile(&fileUrl)
endcomposite
EndEvent
Note:
- All the variables in the previous code examples are defined as VarChar, except for the &file variable that is based on the File type.
- Not all parameters specified in the methods will be shown in all applications when you share content, except for those that are required or accepted by the applications.
- The URL parameter should be complete, following the format <scheme>://<domain>[<port>]/<path>. Otherwise, the URL is considered relative to the Service URL of the application.
Not all third-party application accept any kind of content.
For example,
- Facebook always is exposed as a "share-with" application but does not allow to share plain text, it only allows you sharing images and URLs, but not both at the same time.
- WhatsApp allows you to share images only if text, title, and URL are empty; otherwise, the image will not be sent.
- Twitter ignores title parameters.
- GMail takes the title as the subject of the email and text as its content.
- WeChat on iOS: it is not allowed to share a text without an image/URL.
These limitations depend on the external application receiving the content.
Platforms |
Smart Devices (iOS, Android), Angular |
This external object is available as of GeneXus 15.