Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

How to Implement Target in AndroidSDK using descisionscope and Optimize

Avatar

Level 1

I have refered the github sample app showing only the java code as reference and have implemented the sample in kotlin. I have shared my code fix the issue please. getting response as null only


override fun onCreate() {
super.onCreate()
MobileCore.setLogLevel(LoggingMode.VERBOSE)
MobileCore.initialize(this, LAUNCH_ENVIRONMENT_FILE_ID) {
print("Adobe mobile SDKs are successfully registered.")
}
Log.d("SDKTest", "successsSDK1")
Log.d("SDKTest", "Adobe mobile SDKs are successfully registered.")

val decisionScope = DecisionScope("Android_Test")

val data = mapOf(
"__adobe" to mapOf(
"target" to mapOf(
"a.profile_language" to "en-us",
"a.DeviceName" to "phone"
)
)
)

Optimize.updatePropositions(
listOf(decisionScope),
null,
data,
object : AdobeCallback<Map<DecisionScope, OptimizeProposition>> {
override fun call(propositionsMap: Map<DecisionScope, OptimizeProposition>?) {
val proposition = propositionsMap?.get(decisionScope)
val offers = proposition?.offers
Log.d("SDKTest","SuccessssSDK2")

if (!offers.isNullOrEmpty()) {
val offerContent = offers[0].content
val json = JSONObject(offerContent)
val message = json.optString("test", "No message")
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
} else {
Log.d("TargetOffer", "No offers found for scope ${decisionScope.name} ${propositionsMap?.get(decisionScope)}")
}

if (!offers.isNullOrEmpty()) {
val offerContent = offers[0].content
val json = JSONObject(offerContent)
val message = json.optString("test", "No message"+json.toString())
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
Log.d("TargetOffer",offerContent)
} else {
Log.d("TargetOffer", "No offers found for scope"+offers.toString())
}
}
}
)
}
}
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies