java.lang.Object | |
↳ | co.megacool.megacool.Share |
Shares are created when you call share(Activity)
. If you want to
customize the shared URL or the attached data, call
share(Activity, 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
LinkClickedEvent
. 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 on the ReceivedShareOpenedEvent
. 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.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int |
compareTo(Share other)
Compare shares to determine which is newer.
| ||||||||||
Date |
getCreatedAt()
When the share was created.
| ||||||||||
Map<String, Object> |
getData()
Data associated with the share object to customize the user experience or adding
additional information for each share.
| ||||||||||
String |
getDataAsJson()
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.
| ||||||||||
ShareState |
getState()
How far the share has come towards generating an install.
| ||||||||||
Date |
getUpdatedAt()
When the share object was last updated (changed state).
| ||||||||||
Uri |
getUrl()
Get the URL that is associated with the share object.
| ||||||||||
String | toString() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Comparable
|
Compare shares to determine which is newer. When put in a sorted collection, the newest shares come first.
other | the share to compare to |
---|
0
if the other share was created at the same time as this, a value less
than 0
if the other share is older, a value greater than 0
if the
other share is newer.
When the share was created.
Data associated with the share object to customize the user experience or adding additional information for each share.
Note that properties set in the data(Map)
when the share was created might not
be available on a share received from ReceivedShareOpenedEvent
or
SentShareOpenedEvent
if the network request to create the share failed. Thus you
should always assume a key can be missing from the data.
Data associated with the share object to customize the user experience or adding additional information for each share.
This offers the same functionality as getData()
}, but returns the data
as a JSON formatted string to make it more convenient to use for Unity, etc.
Get the unique referral code for the share.
The referral code is included in the shared link.
How far the share has come towards generating an install.
To get an updated state, call
getShares(Megacool.ShareCallback)
When the share object was last updated (changed state).
Same as getCreatedAt()
if the share has never been updated.
Get the URL that is associated with the share object.
For navigation purposes inside the app you should probably use
getUrl()
instead, as that's computed locally and thus faster and
works offline.
Note that a url set with url(Uri)
when the share was created might be
"/"
(the default) on a share received from ReceivedShareOpenedEvent
or
SentShareOpenedEvent
if the network request to create the share failed.