public class

ShareConfig

extends Object
java.lang.Object
   ↳ co.megacool.megacool.ShareConfig

Class Overview

ShareConfig enables you to customize the share created, to link to a specific section in your game, or add additional data for analytics.

Summary

Public Constructors
ShareConfig()
Build a new empty ShareConfig.
Public Methods
ShareConfig data(Map<String, Object> data)
Set extra data to attach to the share.
ShareConfig dataAsJson(String data)
Set extra data to attach to the share using a JSON formatted String.
ShareConfig fallbackImage(int fallbackImage)
An image that will be shared if there's no frames recorded yet, or the gif creation fails for some reason.
ShareConfig fallbackImageAsset(String fallbackImageAsset)
An image that will be shared if there's no frames recorded yet, or the gif creation fails for some reason.
Map<String, Object> getData()
Get the share's extra data.
int getFallbackImage()
Get the share's fallback image, or 0 if not set.
String getFallbackImageAsset()
Get the path to the share's fallback image, or null if not set.
String getMessage()
Get the share's predefined message.
String getModalTitle()
Get the title of the share modal.
String getRecordingId()
Get the identifier of the recording that will be shared.
SharingStrategy getStrategy()
Get the share's sharing strategy.
Uri getUrl()
Get the custom url for the share, or null if none is set.
void instrument(JsonObject object, String key)
ShareConfig message(String message)
Set the predefined message that's used when calling share(Activity)
ShareConfig modalTitle(String modalTitle)
Set the title of the modal that presents the apps the user can share to.
ShareConfig recordingId(String recordingId)
Which recording to share.
ShareConfig strategy(SharingStrategy strategy)
Set the SharingStrategy to be used when sharing to apps that support text or media, but not both.
String toString()
ShareConfig url(Uri url)
The URL path to share.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ShareConfig ()

Build a new empty ShareConfig.

Public Methods

public ShareConfig data (Map<String, Object> data)

Set extra data to attach to the share.

This can be used to include extra, trusted data in the share that is not visible in the URL. Note that even though the data is not immediately visible to the user like the URL is, it is not suitable for storing any sort of secret data, anyone with the URL of a share can get access to its data.

Parameters
data Data to include in the share. Must be encodable as JSON, thus no complex types.

public ShareConfig dataAsJson (String data)

Set extra data to attach to the share using a JSON formatted String.

This offers the same functionality as data(Map), but with a String argument to make it more convenient to use for Unity, etc.

Parameters
data Data to include in the share. Must be encodable as JSON.

public ShareConfig fallbackImage (int fallbackImage)

An image that will be shared if there's no frames recorded yet, or the gif creation fails for some reason.

Parameters
fallbackImage an image that will be shared if there is no gif
Returns
  • the builder

public ShareConfig fallbackImageAsset (String fallbackImageAsset)

An image that will be shared if there's no frames recorded yet, or the gif creation fails for some reason.

The asset can be either an image file or a .gif.

Parameters
fallbackImageAsset the name of an asset that will be shared if there is no gif
Returns
  • the builder

public Map<String, Object> getData ()

Get the share's extra data.

Returns
  • the share data

public int getFallbackImage ()

Get the share's fallback image, or 0 if not set.

Returns
  • the fallback image resource, or 0.

public String getFallbackImageAsset ()

Get the path to the share's fallback image, or null if not set.

Returns
  • the path to the fallback image, or null.

public String getMessage ()

Get the share's predefined message.

Returns
  • the message

public String getModalTitle ()

Get the title of the share modal.

Returns
  • the title of the share modal

public String getRecordingId ()

Get the identifier of the recording that will be shared.

Returns
  • the recording identifier

public SharingStrategy getStrategy ()

Get the share's sharing strategy.

Returns
  • the sharing strategy

public Uri getUrl ()

Get the custom url for the share, or null if none is set.

This does not include the referral code that will be included when shared.

Returns
  • the share's url, or null.

public void instrument (JsonObject object, String key)

public ShareConfig message (String message)

Set the predefined message that's used when calling share(Activity)

Parameters
message The sharing text

public ShareConfig modalTitle (String modalTitle)

Set the title of the modal that presents the apps the user can share to.

The default is "Share GIF".

Parameters
modalTitle the title of the share modal

public ShareConfig recordingId (String recordingId)

Which recording to share. Only needed if you set a recordingId during capture.

Parameters
recordingId the recordingId used when recording
Returns
  • the builder

public ShareConfig strategy (SharingStrategy strategy)

Set the SharingStrategy to be used when sharing to apps that support text or media, but not both. Defaults to LINK

Parameters
strategy One of LINK or MEDIA

public String toString ()

public ShareConfig url (Uri url)

The URL path to share.

You can encode any data you want into the URL parameters to ensure they are available to the recipient immediately when they open the app, as getUrl().

Note that only the path, query and fragment are used. The absolute share url will be https://<base-url><url>?_m=<referral-code>. The default base url is mgcl.co/<app-identifier>, but can be changed with baseUrl(Uri).