设置回传来在 SDK 向 Adjust 发送信息时触发函数。您可以针对 会话 和 事件 设置回传。
重要提示: 您必须在初始化 SDK 之前 注册回传。
会话回传
设置会话回传来在 SDK 向 Adjust 发送会话信息时触发函数。您可以创建 success 回传和 failure 回传。SDK 向 Adjust 服务器发送信息时会触发 success 回传。SDK 向 Adjust 发送信息时出现问题会触发 failure 回传。
会话回传可访问响应数据对象。您可以在回传函数中使用其属性。
属性 数据类型 描述 Message
String
服务器信息或者 SDK 记录的错误信息。 Timestamp
String
来自 Adjust 服务器的时间戳。 Adid
String
由 Adjust 提供的设备唯一标识符。 JsonResponse
Dictionary <String, Object>
带服务器响应的 JSON 对象。 WillRetry
Boolean
指示包发送失败后是否再次尝试发送。
success 回传
public void setOnSessionTrackingSucceededListener (OnSessionTrackingSucceededListener onSessionTrackingSucceededListener)
设置 success 回传来在 SDK 记录到会话时触发函数。
val config = AdjustConfig ( this , appToken, environment)
config. setOnSessionTrackingSucceededListener (new OnSessionTrackingSucceededListener () {
override fun onFinishedSessionTrackingSucceeded (sessionSuccessResponseData: AdjustSessionSuccess ) {
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnSessionTrackingSucceededListener ( new OnSessionTrackingSucceededListener () {
public void onFinishedSessionTrackingSucceeded (AdjustSessionSuccess sessionSuccessResponseData ) {
function sessionSuccessCallback ( sessionSuccessResponseData ) {}
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setSessionSuccessCallback (sessionSuccessCallback);
Adjust. onCreate (adjustConfig);
示例
This example shows how to create a callback function sessionSuccess
and register it as a success callback. The function logs the timestamp at which the SDK recorded the session.
val config = AdjustConfig ( this , appToken, environment)
config. setOnSessionTrackingSucceededListener (new OnSessionTrackingSucceededListener () {
override fun sessionSuccess (sessionSuccessResponseData: AdjustSessionSuccess ) {
Log. v ( "Session recorded at " + sessionSuccessResponseData.Timestamp)
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnSessionTrackingSucceededListener ( new OnSessionTrackingSucceededListener () {
public void sessionSuccess (AdjustSessionSuccess sessionSuccessResponseData ) {
Log. v ( "Session recorded at " + sessionSuccessResponseData.Timestamp)
function sessionSuccess ( sessionSuccessResponseData ) {
console. log ( "Session recorded at " + sessionSuccessResponseData.Timestamp);
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setSessionSuccessCallback (sessionSuccess);
Adjust. onCreate (adjustConfig);
failure 回传
public void setOnSessionTrackingFailedListener (OnSessionTrackingFailedListener onSessionTrackingFailedListener)
设置 failure 回传来在 SDK 未能记录到会话时触发函数。
val config = AdjustConfig ( this , appToken, environment)
config. setOnSessionTrackingFailedListener (new OnSessionTrackingFailedListener () {
override fun onFinishedSessionTrackingFailed (sessionFailureResponseData: AdjustSessionFailure ) {
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnSessionTrackingFailedListener ( new OnSessionTrackingFailedListener () {
public void onFinishedSessionTrackingFailed (AdjustSessionFailure sessionFailureResponseData ) {
function sessionFailureCallback ( sessionFailureResponseData ) {}
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setSessionFailureCallback (sessionFailureCallback);
Adjust. onCreate (adjustConfig);
示例
This example shows how to create a callback function sessionFailure
and register it as a failure callback. The function logs the session failure message.
val config = AdjustConfig ( this , appToken, environment)
config. setOnSessionTrackingFailedListener (new OnSessionTrackingFailedListener () {
override fun sessionFailure (sessionFailureResponseData: AdjustSessionFailure ) {
Log. v ( "Session recording failed. Response: " + sessionFailureResponseData.Message)
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnSessionTrackingFailedListener ( new OnSessionTrackingFailedListener () {
public void sessionFailure (AdjustSessionFailure sessionFailureResponseData ) {
Log. v ( "Session recording failed. Response: " + sessionFailureResponseData.Message)
function sessionFailure ( sessionFailureResponseData ) {
"Session recording failed. Response: " +
sessionFailureResponseData.Message,
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setSessionFailureCallback (sessionFailure);
Adjust. onCreate (adjustConfig);
事件回传
设置事件回传来在 SDK 向 Adjust 发送事件信息时触发函数。您可以创建 success 回传和 failure 回传。SDK 向 Adjust 服务器发送信息时会触发 success 回传。SDK 向 Adjust 发送信息时出现问题会触发 failure 回传。
事件回传可访问响应数据对象。您可以在回传函数中使用其属性。
属性 数据类型 描述 Message
String
服务器信息或者 SDK 记录的错误信息。 Timestamp
String
来自 Adjust 服务器的时间戳。 Adid
String
由 Adjust 提供的设备唯一标识符。 EventToken
String
事件识别码 CallbackId
String
事件对象上设置的自定义回传 ID JsonResponse
Dictionary <String, Object>
带服务器响应的 JSON 对象。 WillRetry
Boolean
指示包发送失败后是否再次尝试发送。
success 回传
public void setOnEventTrackingSucceededListener (OnEventTrackingSucceededListener onEventTrackingSucceededListener)
设置 success 回传来在 SDK 记录到事件时触发函数。
val config = AdjustConfig ( this , appToken, environment)
config. setOnEventTrackingSucceededListener (new OnEventTrackingSucceededListener () {
override fun onFinishedEventTrackingSucceeded (eventSuccessResponseData: AdjustEventSuccess ) {
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnEventTrackingSucceededListener ( new OnEventTrackingSucceededListener () {
public void onFinishedEventTrackingSucceeded (AdjustEventSuccess eventSuccessResponseData ) {
function eventSuccessCallback ( eventSuccessResponseData ) {}
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setEventSuccessCallback (eventSuccessCallback);
Adjust. onCreate (adjustConfig);
示例
This example shows how to create a callback function eventSuccess
and register it as a success callback. The function logs the timestamp at which the SDK recorded the event.
val config = AdjustConfig ( this , appToken, environment)
config. setOnEventTrackingSucceededListener (new OnEventTrackingSucceededListener () {
override fun eventSuccess (eventSuccessResponseData: AdjustEventSuccess ) {
Log. v ( "Event recorded at " + eventSuccessResponseData.Timestamp)
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnEventTrackingSucceededListener ( new OnEventTrackingSucceededListener () {
public void eventSuccess (AdjustEventSuccess eventSuccessResponseData ) {
Log. v ( "Event recorded at " + eventSuccessResponseData.Timestamp)
function eventSuccess ( eventSuccessResponseData ) {
console. log ( "Event recorded at " + eventSuccessResponseData.Timestamp);
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setEventSuccessCallback (eventSuccess);
Adjust. onCreate (adjustConfig);
failure 回传
public void setOnEventTrackingFailedListener (OnEventTrackingFailedListener onEventTrackingFailedListener)
设置 failure 回传来在 SDK 未能记录到事件时触发函数。
val config = AdjustConfig ( this , appToken, environment)
config. setOnEventTrackingFailedListener ( OnEventTrackingFailedListener () {
override fun onFinishedEventTrackingFailed (eventFailureResponseData: AdjustEventFailure ) {
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnEventTrackingFailedListener ( new OnEventTrackingFailedListener () {
public void onFinishedEventTrackingFailed (AdjustEventFailure eventFailureResponseData ) {
function eventFailureCallback ( eventFailureResponseData ) {}
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setEventFailureCallback (eventFailureCallback);
Adjust. onCreate (adjustConfig);
示例
This example shows how to create a callback function eventFailure
and register it as a failure callback. The function logs the event failure message.
val config = AdjustConfig ( this , appToken, environment)
config. setOnEventTrackingFailedListener (new OnEventTrackingFailedListener () {
override fun eventFailure (eventFailureResponseData: AdjustEventFailure ) {
Log. v ( "Event recording failed. Response: " + eventFailureResponseData.Message)
AdjustConfig config = new AdjustConfig ( this , appToken, environment);
config. setOnEventTrackingFailedListener ( new OnEventTrackingFailedListener () {
public void eventFailure (AdjustEventFailure eventFailureResponseData ) {
Log. v ( "Event recording failed. Response: " + eventFailureResponseData.Message)
function eventFailure ( eventFailureResponseData ) {
"Event recording failed. Response: " + eventFailureResponseData.Message,
let adjustConfig = new AdjustConfig (appToken, environment);
adjustConfig. setEventFailureCallback (sessionFailure);
Adjust. onCreate (adjustConfig);