Uptick SDK is an Android library designed to integrate personalized offers into your app. This SDK allows developers to render offers based on specific placements with minimal configuration.
order_confirmation
and order_status
.
To include the Uptick SDK in your Android project, add the following to your settings.gradle
:
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { maven { url "https://sdk.uptick.com/maven" } } }
Add the dependency in your app-level build.gradle
file:
dependencies { implementation 'com.uptick:uptick-android:v1.0.7' }
Define two FrameLayout
containers in your layout to host the offers, one for popup offers and one for inline offers. Set both containers to match the parent width and height.
<FrameLayout android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" /> <FrameLayout android:id="@+id/adViewInline" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" />
Create an instance of UptickManager
in your activity or fragment.
val uptickManager = UptickManager()
Define callbacks for handling errors and receiving render types. Dynamically determine where the offer is displayed based on the renderType
.
val uptickView = FrameLayout(this) uptickManager.onRenderTypeReceived = { renderType -> (uptickView.parent as? ViewGroup)?.removeView(uptickView) if (renderType == "popup") { findViewById<FrameLayout>(R.id.adView).addView(uptickView) } else { findViewById<FrameLayout>(R.id.adViewInline).addView(uptickView) } }
Call the initiateView
method with the required parameters to display an offer.
import com.uptick.sdk.model.Placement uptickManager.initiateView( context = this, container = uptickView, integrationId = "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE", placement = "order_confirmation", optionalParams = mapOf("first_name" to "Rebecca") )
UptickManager
supports handling errors during the offer flow. You can define a custom error handler function using the onError
property:
uptickManager.onError = { errorMessage -> // Handle error here, for example, show a Toast or log the error Toast.makeText(context, "Error: $errorMessage", Toast.LENGTH_SHORT).show() }
Here is an example of how to integrate UptickManager
into your project:
val uptickView = FrameLayout(this) val uptickManager = UptickManager() uptickManager.onRenderTypeReceived = { renderType -> (uptickView.parent as? ViewGroup)?.removeView(uptickView) if (renderType == "popup") { findViewById<FrameLayout>(R.id.adView).addView(uptickView) } else { findViewById<FrameLayout>(R.id.adViewInline).addView(uptickView) } } uptickManager.onError = { errorMessage -> Log.e("UptickManager", "Error: $errorMessage") } uptickManager.initiateView(this, uptickView, "integration_id_here", "sdk_order_confirmation")
FrameLayout
and used the appropriate integration ID.