...
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) |
...
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) |
...
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. |
...