In App Message
In-App Messages are notifications sent to your users when they are directly active in your mobile application.
Use the following method to show in-app messages and initialize the RMC:
Visilabs.CreateAPI("OrganizationID", "SiteID", "http://lgr.visilabs.net", "DataSource", "http://rt.visilabs.net" , "Android" , getApplicationContext(), "http://s.visilabs.net/json", "http://s.visilabs.net/actjson", requestTimeout);
Add the required getActivity() parameter to all customEvent() calls:
HashMap<String,String> parameters = new HashMap<String, String>(); parameters.put("OM.exVisitorID", "test@visilabs.com"); parameters.put("OM.sys.AppID", "visilabs"); // Visilabs.CallAPI().customEvent("android-visilab", parameters, getActivity());
The existence of a relevant in-app message for an event controlled by after each customEvent
call. You can create and customize your in-app messages on https://intelligence.relateddigital.com/#Target/TargetingAction/TAList page of RMC administration panel.
There are 9 types of in-app messages:
Pop-up - Image, Header, Text & Button | Mini-icon&text | Full Screen-image |
---|---|---|
Full Screen-image&button | Pop-up - Image, Header, Text & Button | Pop-up-Survey |
Pop-up - NPS with Text & Button | Native Alert & Action Sheet | NPS with Numbers |
NPS & Second Popup | ||
Favorite Attribute Actions
You can access favorite attributes of the Targeting Actions of type Favorite Attribute Action that you defined from the https://intelligence.relateddigital.com/#Target/TargetingAction/TAList/ section on the RMC panel via the mobile application as follows.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //requestAction() or requestActionId() try { VisilabsActionRequest visilabsActionRequest = Visilabs.CallAPI().requestAction(VisilabsConstant.FavoriteAttributeAction); visilabsActionRequest.executeAsyncAction(getVisilabsCallback()); } catch (Exception e) { e.printStackTrace(); } }
public VisilabsCallback getVisilabsCallback() { return new VisilabsCallback() { @Override public void success(VisilabsResponse response) { try { FavsResponse favsResponse = new Gson().fromJson(response.getRawResponse(), FavsResponse.class); String favBrands = favsResponse.getFavoriteAttributeAction()[0].getActiondata().getFavorites().getBrand()[0]; Log.i("Favs 1.Brand", favBrands); } catch (Exception ex) { Log.e("Error", ex.getMessage(), ex); } } @Override public void fail(VisilabsResponse response) { Log.d("Error", response.getRawResponse()); } }; }
Story Actions
Story Looking Banner ve Story Actions
Place the following VisilabsRecyclerView
the desired section of the layout for the implementation of both actions.
<com.visilabs.story.VisilabsRecyclerView android:id="@+id/vrv_story" android:layout_width="match_parent" android:layout_height="wrap_content"/>
After defining the VisilabsRecyclerView
in your class, define the StoryItemClickListener
and define the orientation or action you want to do when clicking each story. Toast Message is shown here for an example.
Then call the VisilabsRecyclerView's
setStoryAction method and add the storyItemClickListener
object to the method.
VisilabsRecyclerView visilabsRecyclerView = findViewById(R.id.vrv_story); StoryItemClickListener storyItemClickListener = new StoryItemClickListener() { @Override public void storyItemClicked(String storyLink) { Toast.makeText(getApplicationContext(), storyLink, Toast.LENGTH_LONG).show(); } }; visilabsRecyclerView.setStoryAction(getApplicationContext(), storyItemClickListener);
You can also set it with Story Action Id.
visilabsRecyclerView.setStoryActionId(getApplicationContext(), "250", storyItemClickListener);
It will appear in your application as long as there is an active story looking banner or story on the panel.
Recommendation
Adding Recommendation Widgets in Mobile Application
You can find the documents required to show personalized product recommendations in your Android mobile application in this section.
Create a VisilabsTargetRequest object and call the executeAsync method of the VisilabsTargetRequest object.
ZoneID is different for each application, so contact RMC team for support. Suggestion widgets such as "Alternative Products" require the product code to be seen as a parameter.
The specification of the callback function is as follows:
VisilabsTargetRequest targetRequest = Visilabs.CallAPI().buildTargetRequest(zoneID, "productCode"); targetRequest.executeAsync(callback);
There is also an overload buildTargetRequest method with which you can pass filters and additional parameters.
List filters = new ArrayList<VisilabsTargetFilter>(); HashMap<String,String> properties = new HashMap<String, String>(); properties.put("OM.extra", "Extra Value"); VisilabsTargetFilter f = new VisilabsTargetFilter(); f.setAttribute("attr1"); f.setFilterType("0"); // There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". f.setValue("value"); filters.add(f); f = new VisilabsTargetFilter(); f.setAttribute("attr2"); f.setFilterType("1"); // There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". f.setValue("value"); filters.add(f); VisilabsTargetRequest targetRequest = Visilabs.CallAPI().buildTargetRequest(zoneID, "productCode", properties, filters); targetRequest.executeAsync(callback);
After the request is completed, the callback function is called depending on the success or failure of the request, so you need to code the callback functions according to your needs as shown below:
VisilabsTargetCallback callback = new VisilabsTargetCallback() { @Override public void success(VisilabsResponse response) { try{ JSONArray array = response.getArray(); if(array != null) { ArrayList<Product> recommendations = new ArrayList<>(); for (int i = 0; i < array.length(); i++) { JSONObject obj = (JSONObject)array.get(i); Product product = new Product(); product.setProductCode(obj.getString("code")); product.setProductName(obj.getString("title")); product.setMediumImageUrl(obj.getString("img")); product.setProductURL(obj.getString("dest_url")); product.setBrand(obj.getString("brand")); product.setOriginalPrice(obj.getDouble("price")); product.setDiscountedPrice(obj.getDouble("dprice")); product.setCurrency(obj.getString("cur")); product.setDiscountCurrency(obj.getString("dcur")); product.setFreeShipping(obj.getBoolean("freeshipping")); product.setShippingOnSameDay (obj.getBoolean("samedayshipping")); product.setRating(obj.getInt("rating")); product.setComment(obj.getInt("comment")); product.setDiscountRate(obj.getDouble("discount")); product.setAttr1(obj.getString("attr1")); product.setAttr2(obj.getString("attr2")); product.setAttr3(obj.getString("attr3")); product.setAttr4(obj.getString("attr4")); product.setAttr5(obj.getString("attr5")); recommendations.add(product); } } }catch (Exception ex){ showToast(ex.getMessage()); Log.e(LOG_TAG, ex.getMessage(), ex); } } @Override public void fail(VisilabsResponse response) { showToast(response.getErrorMessage()); Log.d(LOG_TAG, rawResponse); } };
Mail Subscription Form
After form is created at RMC panel, likewise in-app message, existence of mail subscription form is controlled by after each customEvent
call. It is shown as follows. You need to call overload, which takes Activity in the customEvent parameter. Sample code and visual;
customEvent(String pageName, HashMap<String, String> properties, Activity parent)
Spin to Win
After form is created at RMC panel, likewise in-app message, existence of spin to win is controlled by after each customEvent
call. It is shown as follows. You need to call overload, which takes Activity in the customEvent parameter. Sample code and visual;
customEvent(String pageName, HashMap<String, String> properties, Activity parent)
Spin to Win Full | Spin to Win Half |
---|---|
Scratch to Win
After form is created at RMC panel, likewise in-app message, existence of Scratch to Win is controlled by after each customEvent
call. It is shown as follows. You need to call overload, which takes Activity in the customEvent parameter. Sample code and visual;
customEvent(String pageName, HashMap<String, String> properties, Activity parent)