...
In order to show your user an in-app message, you need to create a targeting action on RMC panel and fill the related fields first. Then, you can trigger the targeting action you created as show below and show it to the user it via your mobile application.
...
Code Block | ||
---|---|---|
| ||
HashMap<String, String> parameters = new HashMap<String, String>(); RelatedDigital.customEvent( context, "In-App Message", parameters, activity ); |
Info |
---|
The parameter parent parameters above cannot be null. If you do not enter an Activity value for paremeter parent parameters, the message is not going to be shown. |
...
Click Action Callback
When the user click clicks on the item that includes a link to navigate to another page, you can define what is going to happen next by setting a callback method. You should set this callback via RelatedDigital.setInAppButtonInterface()
method.
...
Info |
---|
After each click, the SDK calls the callback method that was entered and then removes it. Thus, you should set the callback via |
...
First of all, you need to create a font folder (unless you have one) under res folder in your project.
You can add your font files into the folder (font) you created.
Lastly, you should enter the name of the font file without extension in the user interface.
...
You can use the favorite attributes that you define on RMC->targeting actions in your application as show shown below.
Kotlin
Code Block | ||
---|---|---|
| ||
val callback: VisilabsCallback = object : VisilabsCallback { override fun success(response: VisilabsResponse?) { try { val favsResponse: FavsResponse = Gson().fromJson(response!!.rawResponse, FavsResponse::class.java) val favBrands: String = favsResponse.favoriteAttributeAction!![0].actiondata!!.favorites!!.brand!![0]!! Log.i("Favs 1.Brand", favBrands) } catch (e: Exception) { Log.e("Favorite Attribute", e.message) } } override fun fail(response: VisilabsResponse?) { Log.e("Favorite Attribute", response!!.error!!.message) } } RelatedDigital.getFavorites( context = context, actionId = null, actionType = Constants.FavoriteAttributeAction, visilabsCallback = callback) |
...
Code Block | ||
---|---|---|
| ||
VisilabsCallback callback = new VisilabsCallback() { @Override public void success(VisilabsResponse response) { try { FavsResponse favsResponse = new Gson().fromJson(response.getRawResponse(), FavsResponse.class); String favBrands = favsResponse.getFavoriteAttributeAction().get(0).getActiondata().getFavorites().getBrand()[0]; Log.i("Favs 1.Brand", favBrands); } catch(Exception e) { Log.e("Favorite Attribute", e.getMessage()); } } @Override public void fail(VisilabsResponse response) { Log.e("Favorite Attribute", response.getError().getMessage); } }; RelatedDigital.getFavorites( context, null, Constants.FavoriteAttributeAction, callback); |
Story Manager
PleaseFirst of all, you should put StoryRecyclerView
into wherever you want in your layout.
Code Block | ||
---|---|---|
| ||
<com.relateddigital.relateddigital_android.inapp.story.StoryRecyclerView android:id="@+id/story_recycler_view" android:layout_width="match_parent" android:layout_height="wrap_content" /> |
Plase, Theni you should define a StoryItemClickListener
object and determine what action is going to be taken after a story is clicked.
Then, you should call setStoryAction()
or setStoryActionId()
methods with then StoryItemClickListener
object you defined.
...
Code Block | ||
---|---|---|
| ||
StoryItemClickListener storyItemClickListener = new StoryItemClickListener() { @Override public void storyItemClicked(String storyLink) { //Take the action here by using storyLink variable } }; binding.storyRecyclerView.setStoryAction( context, storyItemClickListener); |
veyawith ID
Kotlin
Code Block | ||
---|---|---|
| ||
val storyItemClickListener = object : StoryItemClickListener { override fun storyItemClicked(storyLink: String?) { //Take the action here by using storyLink variable } } binding.storyRecyclerView.setStoryActionId( context = context, storyId = storyId, storyItemClickListener = storyItemClickListener) |
...
You can use setStoryActionWithRequestCallback()
or setStoryActionIdWithRequestCallback()
methods instead if you want to enter a StoryRequestListener
object. This parameter is for you to take a precaution in case of something goes wrong and the request fails. In this case, you should make the visibility of StoryRecyclerView
View.GONE so that there will not be an empty area in your layout.
...
Code Block | ||
---|---|---|
| ||
StoryItemClickListener storyItemClickListener = new StoryItemClickListener() { @Override public void storyItemClicked(String storyLink) { //Take the action here by using storyLink variable } }; StoryRequestListener storyRequestListener = new StoryRequestListener() { @Override public void onRequestResult(boolean isAvailable) { if (!isAvailable) { //Make the StoryRecyclerView's visibility View.GONE here binding.storyRecyclerView.visibility = View.GONE } } }; binding.storyRecyclerView.setStoryActionWithRequestCallback( context, storyItemClickListener, storyRequestListener); |
setStoryActionIdWithRequestCallbackwith ID
Kotlin
Code Block | ||
---|---|---|
| ||
val storyItemClickListener = object : StoryItemClickListener { override fun storyItemClicked(storyLink: String?) { //Take the action here by using storyLink variable } } val storyRequestListener = object : StoryRequestListener { override fun onRequestResult(isAvailable: Boolean) { if (!isAvailable) { //Make the StoryRecyclerView's visibility View.GONE here binding.storyRecyclerView.visibility = View.GONE } } } binding.storyRecyclerView.setStoryActionIdWithRequestCallback( context = context, storyId = storyId, storyItemClickListener = storyItemClickListener, storyRequestListener = storyRequestListener) |
...
Code Block | ||
---|---|---|
| ||
StoryItemClickListener storyItemClickListener = new StoryItemClickListener() { @Override public void storyItemClicked(String storyLink) { //Take the action here by using storyLink variable } }; StoryRequestListener storyRequestListener = new StoryRequestListener() { @Override public void onRequestResult(boolean isAvailable) { if (!isAvailable) { //Make the StoryRecyclerView's visibility View.GONE here binding.storyRecyclerView.visibility = View.GONE } } }; binding.storyRecyclerView.setStoryActionIdWithRequestCallback( context, storyId, storyItemClickListener, storyRequestListener); |
Recommendations Action
You can trigger recommendations action in your application as shown below:
Kotlin
App Banner
You should put BannerRecyclerView
into a layout file that you prefer in your project. An example usage:
Code Block | ||
---|---|---|
| ||
val callback: VisilabsCallback = object : VisilabsCallback { override fun success(response: VisilabsResponse?) { try { //You can take the action here with the recommendations' response. Example, val jsonObject = response!!.json <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.relateddigital.relateddigital_android.inapp.bannercarousel.BannerRecyclerView android:id="@+id/bannerListView" val groupTitle = jsonObject!!.getString("title") android:layout_width="match_parent" val jsonArray = jsonObject.getJSONArray("recommendations")android:layout_height="150dp"/> <Button for (i in 0 until jsonArray.length()) { android:id="@+id/btn_show_banner" val currentProductObject = jsonArray.getJSONObject(i)android:layout_gravity="center" val currentProductTitle = currentProductObject.getString("title")android:layout_width="150dp" val currentProductPrice = currentProductObject.getDouble("price")android:layout_height="50dp" val currentProductFreeShipping = currentProductObject.getBoolean("freeshipping")android:layout_marginTop="20dp" val qs = currentProductObject.getString("qs")android:background="@drawable/rounded_corners_background" android:text="@string/show_banner" /Continues like this... } } catch (e: Exception) { Log.e("Recommendations", e.message) } } override fun fail(response: VisilabsResponse?) { Log.e("Recommendations", response!!.error!!.> </LinearLayout> |
After putting BannerRecyclerView
, you should access the object in the related program code (Java or Kotlin) and you should call the method requestBannerCarouselAction
() on this object. This method takes 1 mandatory (context: Context
) and 3 optional parameters (properties: HashMap<String, String>?, bannerRequestListener: BannerRequestListener?, bannerItemClickListener: BannerItemClickListener?
).
properties
is for adding extra query parameters you want, to the request.
bannerRequestListener
is for making the visibility of BannerRecyclerView
object View.GONE or View.VISIBLE if something goes wrong in the process so that the related area on the screen won’t be empty.
bannerItemClickListener
is for getting the control when the user clicks on a banner. If you don’t want the SDK to direct the user to the link automatically, you can use this interface.
You can find an example usage that includes all parameters, below:
Kotlin
Code Block | ||
---|---|---|
| ||
val bannerItemClickListener = object : BannerItemClickListener {
override fun bannerItemClicked(bannerLink: String?) {
if(bannerLink.isNullOrEmpty()) {
return
}
Toast.makeText(applicationContext, bannerLink, Toast.LENGTH_SHORT).show()
Log.i("link banner", bannerLink)
try {
val viewIntent = Intent(Intent.ACTION_VIEW, Uri.parse(bannerLink))
startActivity(viewIntent)
} catch (e: Exception) {
Log.e(LOG_TAG, "The link is not formatted properly!")
}
}
}
val bannerRequestListener = object : BannerRequestListener {
override fun onRequestResult(isAvailable: Boolean) {
if (!isAvailable) {
binding?.bannerListView.visibility = View.GONE
}
}
}
val properties = HashMap<String, String>()
properties["OM.inapptype"] = "banner_carousel"
binding?.bannerListView.requestBannerCarouselAction(
context = applicationContext,
properties = properties,
bannerRequestListener = bannerRequestListener,
bannerItemClickListener = bannerItemClickListener
) |
Java
Code Block | ||
---|---|---|
| ||
BannerItemClickListener bannerItemClickListener = new BannerItemClickListener() {
@Override
public void bannerItemClicked(String bannerLink) {
if(bannerLink == null || bannerLink.isEmpty()) {
return;
}
Toast.makeText(getApplicationContext(), bannerLink, Toast.LENGTH_SHORT).show();
Log.i("link banner", bannerLink);
try {
Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bannerLink));
startActivity(viewIntent);
} catch (Exception e) {
Log.e(LOG_TAG, "The link is not formatted properly!");
}
}
};
BannerRequestListener bannerRequestListener = new BannerRequestListener() {
@Override
public void onRequestResult(boolean isAvailable) {
if (!isAvailable) {
binding.bannerListView.visibility = View.GONE;
}
}
};
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("OM.inapptype", "banner_carousel");
binding.bannerListView.requestBannerCarouselAction(
applicationContext,
properties,
bannerRequestListener,
bannerItemClickListener
); |
Recommendations Action
You can trigger recommendations action in your application as shown below:
Kotlin
Code Block | ||
---|---|---|
| ||
val callback: VisilabsCallback = object : VisilabsCallback {
override fun success(response: VisilabsResponse?) {
try {
//You can take the action here with the recommendations' response. Example,
val jsonObject = response!!.json
val groupTitle = jsonObject!!.getString("title")
val jsonArray = jsonObject.getJSONArray("recommendations")
for (i in 0 until jsonArray.length()) {
val currentProductObject = jsonArray.getJSONObject(i)
val currentProductTitle = currentProductObject.getString("title")
val currentProductPrice = currentProductObject.getDouble("price")
val currentProductFreeShipping = currentProductObject.getBoolean("freeshipping")
val qs = currentProductObject.getString("qs")
//Continues like this...
}
} catch (e: Exception) {
Log.e("Recommendations", e.message)
}
}
override fun fail(response: VisilabsResponse?) {
Log.e("Recommendations", response!!.error!!.message)
}
}
RelatedDigital.getRecommendations(
context = context,
zoneId = "zoneIdValue",
productCode = "productCodeValue",
visilabsCallback = callback) |
...
Also, you can input some filters and extra parameters to getRecommendations()
method.
Kotlin
Code Block | ||
---|---|---|
| ||
val callback: VisilabsCallback = object : VisilabsCallback { override fun success(response: VisilabsResponse?) { try { //You can take the action here with the recommendations' response. Example, val jsonObject = response!!.json val groupTitle = jsonObject!!.getString("title") val jsonArray = jsonObject.getJSONArray("recommendations") for (i in 0 until jsonArray.length()) { val currentProductObject = jsonArray.getJSONObject(i) val currentProductTitle = currentProductObject.getString("title") val currentProductPrice = currentProductObject.getDouble("price") val currentProductFreeShipping = currentProductObject.getBoolean("freeshipping") val qs = currentProductObject.getString("qs") //Continues like this... } } catch (e: Exception) { Log.e("Recommendations", e.message) } } override fun fail(response: VisilabsResponse?) { Log.e("Recommendations", response!!.error!!.message) } } val filters = ArrayList<VisilabsTargetFilter>() val parameters = HashMap<String, String>() parameters["OM.extra"] = "Extra Value" val f1 = VisilabsTargetFilter("attr1", "0", "value1") filters.add(f1) val f2 = VisilabsTargetFilter("attr2", "1", "value2") filters.add(f2) RelatedDigital.getRecommendations( context = context, zoneId = "zoneIdValue", productCode = "productCodeValue", visilabsCallback = callback, properties = parameters, filters = filters) |
...
Code Block | ||
---|---|---|
| ||
VisilabsCallback callback = new VisilabsCallback() { @Override public void success(VisilabsResponse response) { try { //You can take the action here with the recommendations' response. Example, JSONObject jsonObject = response.getJson(); String groupTitle = jsonObject.getString("title"); JSONArray jsonArray = jsonObject.getJSONArray("recommendations"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject currentProductObject = jsonArray.getJSONObject(i); String currentProductTitle = currentProductObject.getString("title"); Double currentProductPrice = currentProductObject.getDouble("price"); Boolean currentProductFreeShipping = currentProductObject.getBoolean("freeshipping"); String qs = currentProductObject.getString("qs"); //Continues like this... } } catch(Exception e) { Log.e("Recommendations", e.getMessage()); } } @Override public void fail(VisilabsResponse response) { Log.e("Recommendations", response.getError().getMessage()); } }; ArrayList<VisilabsTargetFilter> filters = new ArrayList<VisilabsTargetFilter>(); HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("OM.extra", "Extra Value"); VisilabsTargetFilter f1 = new VisilabsTargetFilter("attr1", "0", "value1"); filters.add(f1); VisilabsTargetFilter f2 = new VisilabsTargetFilter("attr2", "1", "value2"); filters.add(f2); RelatedDigital.getRecommendations = new VisilabsTargetFilter("attr2", "1", "value2"); filters.add(f2); RelatedDigital.getRecommendations( context, "zoneIdValue", "productCodeValue", callback, parameters, filters = filters); |
In order the clicks of the recommendations to be reflected on the panel, you should send the “qs” value of the recommendation that is clicked by the user to the server via trackRecommendationClick()
method.
Info |
---|
You can see how to get “qs” value for each recommendation in the example callback method above. |
Kotlin
Code Block | ||
---|---|---|
| ||
RelatedDigital.trackRecommendationClick( context, = "zoneIdValue"context, "productCodeValue", callback, parameters, filters = filters); |
In order the clicks of the recommendations to be reflected on the panel, you should send the “qs” value of the recommendation that is clicked by the user to the server via trackRecommendationClick
method.
Info |
---|
You can see how to get “qs” value for each recommendation in the example callback method above. |
Kotlin
Code Block | ||
---|---|---|
| ||
RelatedDigital.trackRecommendationClick(
context = context,
qs = qs) |
Java
Code Block | ||
---|---|---|
| ||
RelatedDigital.trackRecommendationClick(
context,
qs); |
Mail Subscription Form
...
qs = qs) |
Java
Code Block | ||
---|---|---|
| ||
RelatedDigital.trackRecommendationClick(
context,
qs); |
Mail Subscription Form
You can trigger the mail subscription form that you defined on RMC panel as shown below:
Kotlin
Code Block | ||
---|---|---|
| ||
val parameters = HashMap<String, String>()
RelatedDigital.customEvent(
context = context,
pageName = "Mail Subscription",
properties = parameters,
parent = activity
) |
Java
Code Block | ||
---|---|---|
| ||
HashMap<String, String> parameters = new HashMap<String, String>();
RelatedDigital.customEvent(
context,
"Mail Subscription",
parameters,
activity
); |
...
Info |
---|
Please make sure that you input an Activity with the parameter of parent. If you define a rule for your targeting action on RMC panel, please make sure that you add this rule to the map before calling
|
SpinToWin
You can trigger the spin-to-win action that you defined on RMC panel as shown below:
...
Code Block | ||
---|---|---|
| ||
val parameters = HashMap<String, String>() RelatedDigital.customEvent( context = context, pageName = "Mail SubscriptionSpinToWin", properties = parameters, parent = activity ) |
...
Code Block | ||
---|---|---|
| ||
HashMap<String, String> parameters = new HashMap<String, String>(); RelatedDigital.customEvent( context, "Mail SubscriptionSpinToWin", parameters, activity ); |
...
Çarkıfelek Yarım Görünüm | Çarkıfelek Tam Görünüm |
---|---|
|
|
Info |
---|
Please make sure that you input an Activity with the parameter of parent. If you define a rule for your targeting action on RMC panel, please make sure that you add this rule to the map before calling
|
...
ScratchToWin
You can trigger the spinscratch-to-win action that you defined on RMC panel as shown below:
...
Code Block | ||
---|---|---|
| ||
val parameters = HashMap<String, String>() RelatedDigital.customEvent( context = context, pageName = "SpinToWinScratchToWin", properties = parameters, parent = activity ) |
...
Code Block | ||
---|---|---|
| ||
HashMap<String, String> parameters = new HashMap<String, String>(); RelatedDigital.customEvent( context, "SpinToWinScratchToWin", parameters, activity ); |
...
Çarkıfelek Yarım Görünüm
...
Çarkıfelek Tam Görünüm
...
...
...
Info |
---|
Please make sure that you input an Activity with the parameter of parent. If you define a rule for your targeting action on RMC panel, please make sure that you add this rule to the map before calling
|
...
Product Stat Notifier
You can trigger the scratch-to-win product stat notifier action that you defined on RMC panel as shown below:
Kotlin
Code Block | ||
---|---|---|
| ||
val parameters = HashMap<String, String>() RelatedDigital.customEvent( context = context, pageName = "ScratchToWinProduct Stat Notifier", properties = parameters, parent = activity ) |
Java
Code Block | ||
---|---|---|
| ||
HashMap<String, String> parameters = new HashMap<String, String>(); RelatedDigital.customEvent( context, "ScratchToWinProduct Stat Notifier", parameters, activity ); |
...
Info |
---|
Please make sure that you input an Activity with the parameter of parent. If you define a rule for your targeting action on RMC panel, please make sure that you add this rule to the map before calling
|
...
Drawer
You can trigger the product stat notifier drawer action that you defined on RMC panel as shown below:
Kotlin
Code Block | ||
---|---|---|
| ||
val parameters = HashMap<String, String>() RelatedDigital.customEvent( context = context, pageName = "Product Stat NotifierDrawer", properties = parameters, parent = activity ) |
Java
Code Block | ||
---|---|---|
| ||
HashMap<String, String> parameters = new HashMap<String, String>(); RelatedDigital.customEvent( context, "Product Stat NotifierDrawer", parameters, activity ); |
...
...
Info |
---|
Please make sure that you input an Activity with the parameter of parent. If you define a rule for your targeting action on RMC panel, please make sure that you add this rule to the map before calling
|