public abstract class DDNA
extends java.lang.Object
The singleton instance must first be initialised by calling
initialise(Configuration)
from a Application
's
Application.onCreate()
method. Following this call an instance can
be accessed at any time through instance()
.
Prior to sending events, or performing engagements, the SDK must be started
through startSdk()
or startSdk(String)
. stopSdk()
should be called when the game is stopped.
To customise behaviour after initialisation you can call
getSettings()
to get access to the Settings
.
Modifier and Type | Class and Description |
---|---|
static class |
DDNA.Configuration
Class for providing a configuration when initialising the
SDK through
initialise(Configuration) inside of an
Application class. |
static interface |
DDNA.SettingsModifier |
Modifier and Type | Method and Description |
---|---|
abstract DDNA |
clearPersistentData()
Clears persistent data, such as the user ID, Collect events, and Engage
cache.
|
abstract DDNA |
clearRegistrationId()
Clears the registration id associated with this device for disabling
push notifications.
|
abstract DDNA |
downloadImageAssets()
Downloads image assets from the session configuration in the background.
|
abstract DDNA |
forgetMe()
Forgets the current user and stops them from being tracked.
|
abstract java.lang.String |
getCrossGameUserId()
Gets the cross game user ID used for cross promotion.
|
EngageFactory |
getEngageFactory()
Gets the Engage factory which provides an easier way of requesting
Engage actions.
|
abstract java.lang.String |
getRegistrationId()
Gets the registration id for push notifications.
|
java.lang.String |
getSessionId() |
Settings |
getSettings() |
java.lang.String |
getUserId()
Gets the user id.
|
static DDNA |
initialise(DDNA.Configuration configuration) |
static DDNA |
instance() |
abstract boolean |
isStarted()
Queries the status of the SDK.
|
DDNA |
newSession()
Changes the session id.
|
abstract EventAction |
recordEvent(Event event)
Records an event with Collect.
|
abstract EventAction |
recordEvent(java.lang.String name)
Records an event with Collect.
|
abstract EventAction |
recordNotificationDismissed(android.os.Bundle payload)
Record when a push notification has been dismissed.
|
abstract EventAction |
recordNotificationOpened(boolean launch,
android.os.Bundle payload)
Record when a push notification has been opened.
|
DDNA |
register(EventListener listener)
Registers an
EventListener for receiving event notifications. |
DDNA |
register(IEventListener listener) |
abstract <E extends Engagement> |
requestEngagement(E engagement,
EngageListener<E> listener)
Makes an Engage request.
|
abstract DDNA |
requestEngagement(java.lang.String decisionPoint,
EngageListener<Engagement> listener)
Makes an Engage request.
|
abstract DDNA |
requestSessionConfiguration()
Makes a session configuration request.
|
DDNA |
setAdvertisingId(java.lang.String advertisingId) |
abstract DDNA |
setCrossGameUserId(java.lang.String crossGameUserId)
Sets the cross game user ID for the current user to be used for cross
promotion.
|
abstract DDNA |
setRegistrationId(java.lang.String registrationId)
Sets the registration id for push notifications.
|
abstract DDNA |
startSdk()
Starts the SDK.
|
abstract DDNA |
startSdk(java.lang.String userId)
Starts the SDK.
|
abstract DDNA |
stopSdk()
Stops the SDK.
|
abstract DDNA |
stopTrackingMe()
Stops tracking the current user.
|
DDNA |
unregister(EventListener listener)
Unregisters an
EventListener so that it will no longer receive
event notifications. |
DDNA |
unregister(IEventListener listener) |
abstract DDNA |
upload()
Sends pending events to our platform.
|
public static DDNA initialise(DDNA.Configuration configuration)
public static DDNA instance()
public abstract DDNA startSdk()
This method needs to be called before sending events or making engagements.
DDNA
instancepublic abstract DDNA startSdk(@Nullable java.lang.String userId)
This method needs to be called before sending events or making engagements.
userId
- the user id, may be null
in which case the
SDK will generate an id.DDNA
instancepublic abstract DDNA stopSdk()
Calling this method sends a 'gameEnded' event to Collect, disables background uploads and automatic session refreshing.
DDNA
instancepublic abstract boolean isStarted()
true
if the SDK has been started, else false
public abstract EventAction recordEvent(java.lang.String name)
name
- the name of the eventEventAction
for this eventjava.lang.IllegalArgumentException
- if the name
is null or emptypublic abstract EventAction recordEvent(Event event)
event
- the eventEventAction
for this eventjava.lang.IllegalArgumentException
- if the event
is nullpublic abstract EventAction recordNotificationOpened(boolean launch, android.os.Bundle payload)
launch
- whether the notification launched the apppayload
- the payload of the push notificationEventAction
for this eventpublic abstract EventAction recordNotificationDismissed(android.os.Bundle payload)
payload
- the payload of the push notificationEventAction
for this eventpublic abstract DDNA requestEngagement(java.lang.String decisionPoint, EngageListener<Engagement> listener)
The result will be passed into the provided listener
through
one of the callback methods on the main UI thread, even if this method
was called from a background thread.
decisionPoint
- the decision point for the engagementlistener
- listener for the resultDDNA
instancejava.lang.IllegalArgumentException
- if the decisionPoint
is null
or emptyEngageFactory
public abstract <E extends Engagement> DDNA requestEngagement(E engagement, EngageListener<E> listener)
The result will be passed into the provided listener
through
one of the callback methods on the main UI thread, even if this method
was called from a background thread.
engagement
- the engagementlistener
- listener for the resultDDNA
instancejava.lang.IllegalArgumentException
- if the engagement
is nullEngageFactory
public abstract DDNA requestSessionConfiguration()
The result will be notified via the
EventListener.onSessionConfigured(boolean)
or
EventListener.onSessionConfigurationFailed(Throwable)
callback
methods for any registered EventListener
s.
DDNA
instancepublic abstract DDNA upload()
This is usually called automatically, but in the case that automatic event uploads are disabled the game will be responsible for calling this method at suitable points in the game flow.
DDNA
instancepublic abstract DDNA downloadImageAssets()
This happens automatically whenever a session configuration request
takes places, such as during a new session or when
requestSessionConfiguration()
is called.
The success or failure will be notified to all registered
EventListener
s.
DDNA
instance@Nullable public abstract java.lang.String getCrossGameUserId()
null
if not setpublic abstract DDNA setCrossGameUserId(java.lang.String crossGameUserId)
crossGameUserId
- the cross game user IDDDNA
instancejava.lang.IllegalArgumentException
- if the crossGameUserId
is null
or empty@Nullable public abstract java.lang.String getRegistrationId()
null
if not setpublic abstract DDNA setRegistrationId(@Nullable java.lang.String registrationId)
registrationId
- the registration id, may be null
in order to unregister from notificationsDDNA
instancepublic abstract DDNA clearRegistrationId()
DDNA
instancepublic abstract DDNA clearPersistentData()
This also normally stops the SDK, as a re-start will be required in order to re-initialise the user ID.
DDNA
instancepublic abstract DDNA forgetMe()
Any subsequent calls on the SDK will succeed, but not send/request anything to/from the Platform.
The status can be cleared by starting the SDK with a new user through
startSdk(String)
or by clearing the persistent data with
clearPersistentData()
.
DDNA
instancepublic abstract DDNA stopTrackingMe()
Any subsequent calls on the SDK will succeed, but not send/request anything to/from the Platform.
The status can be cleared by starting the SDK with a new user through
startSdk(String)
or by clearing the persistent data with
clearPersistentData()
.
DDNA
instancepublic final java.lang.String getSessionId()
@Nullable public final java.lang.String getUserId()
null
if the user id hasn't
been set or generated by the SDK at this pointpublic final EngageFactory getEngageFactory()
EngageFactory
public final Settings getSettings()
public final DDNA register(EventListener listener)
EventListener
for receiving event notifications.listener
- the listener to registerDDNA
instancepublic final DDNA unregister(EventListener listener)
EventListener
so that it will no longer receive
event notifications.listener
- the listener to unregisterDDNA
instancepublic final DDNA register(IEventListener listener)
public final DDNA unregister(IEventListener listener)
public DDNA setAdvertisingId(@Nullable java.lang.String advertisingId)