To integrate Challenges into Android, you need to make sure that the basic integration of the Nudge Core SDK is done, if you have not already done it, check here.
If you are not using the (nudge:sdk
), then you would need to install the Challenges SDK,
Add the following to your build.gradle
or settings.gradle
according to your package setup:
maven{
url "https://github.com/nudgenow/libraries/raw/main/challenges/"
}
maven {
url "https://github.com/nudgenow/libraries/raw/main/sdk/"
}
Once done, add the following to your project settings.gradle
include ':challenges'
include ':sdk'
Once you install the challenges
package, follow the steps below to complete the integration.
Once you have integrated the Nudge Code SDK, just add the above-defined variable into the list inplugins
property of Nudge
NudgeUi challengesUi = new ChallengesUi(); // This is not a typo, ChallengesUi is of type NudgeUi
NudgeProvider(this, nudge, Arrays.asList(challengesUi)); // Along with any other plugins
val nudgesUi = NudgesUi()
nudgeProvider = NudgeProvider(this,
nudge,
Arrays.asList(nudgesUi) // Along with the others
)
That's it!
Our Nudge Core would now trigger Challenges defined on your Dashboard using the Challenges
plugin.
Add-on Integrations
Callback Function
The getCallBack
function from the Nudge class enables you to set up a callback mechanism to receive notifications from any screen within the Nudge package. This feature proves particularly useful when handling specific actions or events, such as a Call-to-Action (CTA) callback following a nudge flow completion, which includes a URL link to redirect the user to a desired location.
Example:
void printCallback(JSONObject response) {
printFunction(response);
}
challengesUi.getCallBack(printCallback)
NudgeProvider(this, nudge, Arrays.asList(challengesUi)); // Along with any other plugins