public class

Share

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

Class Overview

Shares are created when you call share(). If you want to customize the shared URL or the attached data, call Megacool#share(ShareConfig) with a customized ShareConfig object. If another user opens the app from the link shared, they can retrieve the original Share and the data attached to it.

The two data points you can attach to a share serve different purposes; if you want to link to a specific section of your app, you should use the URL for that, and retrieve the URL in the LINK_CLICKED event. The URL is available to the receiving device without any network involvement, and is thus fast and reliable, and thus suitable for navigation within the app. The data has to be retrieved from the servers, and will thus only be available when there is network connectivity. The data is mostly useful for analytics, for example if you attach a field "level" with name of the current level the user is playing, we can tell you which levels are shared the most or generate the most installs. This doesn't happen automatically yet, contact us for recommendations on how to proceed with this so that we can fetch the data you want.

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.

Summary

Public Methods
Date getCreatedAt()
When the share object was created
Map<String, String> getData()
Data associated with the share object to customize the user experience or adding additional information for each share.
ReferralCode getReferralCode()
Get the unique referral code for the share.
String getShareId()
ShareState getState()
The state of the share.
Date getUpdatedAt()
When the share object was last updated (changed state).
Uri getUrl()
Get the URL that is associated with the share object.
Boolean isSubmitted()
void setIsSubmitted(Boolean submitted)
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public Date getCreatedAt ()

When the share object was created

public Map<String, String> getData ()

Data associated with the share object to customize the user experience or adding additional information for each share.

public ReferralCode getReferralCode ()

Get the unique referral code for the share.

The referral code is included in the shared link. The referral code is assigned when the share is shared, thus not available when you've instantiated the share yourself.

public String getShareId ()

public ShareState getState ()

The state of the share. 4 types of states:

To receive the latest update of the state, call getShares(Megacool.ShareCallback)

public Date getUpdatedAt ()

When the share object was last updated (changed state).

public Uri getUrl ()

Get the URL that is associated with the share object.

This is the URL you should use to navigate within the app, but the shared url will have https://mgcl.co/"yourIdentifier" prepended and _m="referralCode" appended to it. If not set it defaults to "/". The URL will be normalized by adding leading slash to the path if absent, and stripping any trailing slash.

public Boolean isSubmitted ()

public void setIsSubmitted (Boolean submitted)

public String toString ()