Introduction

Optimise publisher SDK enables publishers to embed coupons and product feeds into their apps. It is simple and easy to integrate. It is compatible with the android version 2.3 and above.

Below are the key points covered in this guide:-

1. Download the SDK and demonstrator app

Download the Demonstrator App from Google Play

Download the Android SDK 1.0.7

2. Update in this version

  • Introduced an optional setCategory() method to SDK. You can set category name to show particular category of vouchers & offers. You can check display coupon wall to use this method.

3. Overview

The following document outlines the various steps for integrating Optimise Native Content Publisher SDK. The SDK is a library used for displaying Product Feeds and Coupons, Vouchers & Offers in native apps. Developers can customise the “Product Wall” UI according to their app’s design. See Styling SDK to style wall.

4. Requirements

To add Optimise Native Content Publisher SDK you will need the latest version of Android Studio (Android studio is the official IDE for android application development).

5. Adding the SDK to your App

i. Import

Select import .JAR or .AAR package

choose_import

ii. Add OptimisePublisherSdk.aar

Add OptimisePublisherSdk.aar from the path where you saved the file.

select_file_from_path

iii. Add Module Dependency

Add optimisepublishersdk as module dependency in project as shown below.

add_publisher_sdk_as_module

iv. Add permissions in Manifest file

You need to add the following permissions to your Manifest.

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="ANDROID.PERMISSION.ACCESS_WIFI_STATE"/>

v. How to Call PublisherSdk Methods

//Get instance of OptimisePublisherSdk
OptimisePublisherSdk optimisePublisherSdk = OptimisePublisherSdk.getInstance();

Global Parameters

//Set API Secret, ApiKey and AID the following parameters should be called only once in the code
OptimisePublisherSdk.AID = AID;
OptimisePublisherSdk.API_KEY = API_KEY;
OptimisePublisherSdk.API_SECRET = API_SECRET;
OptimisePublisherSdk.UID = UID;
Parameter Required? Format Description
AID Yes int  Affiliate ID of publisher
ApiKey Yes String ApiKey of publisher
ApiSecret Yes String Private key of publisher
UID Optional String Unique ID to be added in Optimise tracking links.

Display Product wall:

Set currency pre-reduction type
Developer can set the currency pre-reduction type by setting its value to code. The pre-reduction type will be only shown if product has discounted amount. This method should be called before calling the load product wall.

e.g :-
productWall.setCurrencyPreReductionType(CurrencyPrereduction.CURRENCY_REDUCTION_TYPE_STRIKE_THROUGH);

Following are the different types

//By default there will be nothing to add before original amount of product.
CURRENCY_REDUCTION_TYPE_NONE

//This will strike off the original amount.
CURRENCY_REDUCTION_TYPE_STRIKE_THROUGH

//This will add “was” word before the original amount of product.
CURRENCY_REDUCTION_TYPE_WAS

//This will add “before” word before the original amount of product.
CURRENCY_REDUCTION_TYPE_BEFORE

//Call load product wall method where developer want to show the products

optimisePublisherSdk.loadProductwall (AgencyId, MID, Keyword, MinPrice, MaxPrice, Currency, DiscountedOnly,ProductSKU,NumberOfRecords, ProductWallType, View, Context);
Parameter Required? Data Type Description
AgencyId Yes int Agency Id of the publisher
MID No int Merchant Id – This value can be a 0 if not required
Keyword Yes String Keyword to search for e.g. “iphone 6″
MinPrice No float The minimum price – This value can be a 0 if not required
MaxPrice No float The maximum price – This value can be a 0 if not required
Currency Yes String 3 digit ISO standard currency code
DiscountedOnly No boolean Only displays items with a discount – default value = false
ProductSKU No String Display a single product by its SKU
NumberOfRecords Yes int Number of records to display in product wall
ProductWallType Yes int Type of product wall publisher want to display. More info.
View  Yes Integer ID of frame layout where you want to display Product Wall. E.g. R.id.frame_layout
Context Yes Object (Activity) The activity reference

Enable/Disable search box:

You can set the visibility of search box in coupon wall. For this you need to call following method of SDK.

OptimisePublisherSdk.getInstance().setSearchBoxVisible(true);

This is an optional feature. If you do not set this true/false it will be by default true.

Display Coupon Wall:

Set the duration in DD/MM/YYYY format for loading coupons. This is optional as SDK will take care of this if not provided.

OptimisePublisherSdk.getInstance().setStartDate(startDate);
OptimisePublisherSdk.getInstance().setEndDate(endDate);

Set category to SDK. This is also an optional method if you do not set anything than by default SDK will load all
available coupons.
If you set any value to this method than SDK will show only coupons related to that category.

OptimisePublisherSdk.getInstace().setCategory(Category);

Below are few categories example which you can set to SDK:-

  • Apparel and Accessories
  • Automotive
  • Beauty and Personal Care
  • Books and Stationary
  • Bus Tickets
  • Cameras and Accessories
  • Computers, Laptops and Gaming
  • Electronics
  • Entertainment
  •  Fashion
  • Flowers and Gifts
  • Food and Beverages
  • Footwear
  • Grocery
  • Health
  • Home and Decor
  • Home and Kitchen
  • Hotels
  • Industrial Supplies
  • Innerwear and Swimwear
  • Jewellery and Coins
  • Kids and Babies
  • Miscellaneous
  • Mobile Recharge and Bill Payment
  • Mobiles and Tablets
  • Musical Instruments
  • Other
  • Sports and Fitness
  • Travel and Tours
  • Utility Appliances
//Call load product wall method where developer want to show the products
productWall.loadCoupons(AgencyId, Status, ProductWallType, View, Keyword,Context);
Parameter Required? Data Type Description
AgencyId Yes String Agency Id of the publisher
Status Optional String Status can be “Active”, “Pending”, “Expired” or you can leave this as empty string
ProductWallType Yes Integer Type of product wall publisher want to display. More info.
View  Yes  Integer  ID of frame layout where you want to display Product Wall. E.g. R.id.frame_layout
Keyword  Optional  String  Keyword for the coupon to load. You can set name of the merchant whose coupon you want to display in wall. This is an optional feature,  It will display all coupons if it is left empty.
Context Yes Object (Activity) The activity reference

vi. Setting ProductWallType

There are 5 different options for displaying a product wall. Choose from one of the following values:

  • Vertical wall with small cells: ProductWallType.PRODUCT_WALL_TYPE_SMALL_CELL
  • Vertical wall with large cells: ProductWallType.PRODUCT_WALL_TYPE_LARGE_CELL (Large Cell is added only for Product Wall. In case of Voucher Code this option will not work.)
  • 3D Carousel wall with large cells: ProductWallType.PRODUCT_WALL_TYPE_CAROUSEL
  • Marquee wall with small cells: ProductWallType.PRODUCT_WALL_TYPE_MARQUEE
  • Grid wall having grid view cells: ProductWallType.PRODUCT_WALL_TYPE_GRID

vii. Styling SDK

Publisher can also customize the styling of publisher sdk according to their application. Styling can be done by overriding following styles to Styles.xml file under values folder of project.

Defining fonts
Developer can apply their fonts to wall by overriding following keywords to their strings.xml file under values folder.

// strings for custom fonts

<string name="custom_font_normal">Intelligent Design - Zona Pro.otf</string>
<string name="custom_font_black">Intelligent Design - Zona Pro Black.otf</string>
<string name="custom_font_bold">Intelligent Design - Zona Pro.otf</string>

Defining shape for buy button
Developer can define their own shapes for buy button. For this one need to override the buy_button_clicked_state.xml and buy_button_normal_state.xml to their drawable folder under resources.

e.g. buy_button_clicked.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="0dp"
android:color="#000000"/>
<solid android:color="#000000"/>
<corners android:radius="0dp" />
</shape>

Same can be used for buy_button_normal_state.xml shape only color can be changed

Defining shape for share button:
Developer can define their own shapes for share button. For this also one need to override share_clicked_state.xml and share_normal_state.xml file in their drawable folder under resources.

e.g. share_normal_state

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="0dp"
android:color="#000000"/>
<solid android:color="#000000"/>
<corners android:radius="0dp"/>
<shape> 

Same can be used for share_normal_state.xml shape only color can be changed

Adding color and text size to text views
Developer can style text views according to their application. To achieve this one need to override following style to their styles.xml file in resources under values folder:

Common Style for vouchers and products description

<!–Style for text view product description of cell of the product wall–>

<style name="Widget_TextView_Product_Description"> 
<item name="android:textColor">@color/text_color_product_description </item > 
<item name="android:textSize">@dimen/text_size_12sp</item> <style>

<!–Style for text view original amount of cell of the product wall–>

<style name="Widget_TextView_Original_Amount">
<item name="android:textColor">@color/text_color_original_amount</item >
< item name="android:textSize">@dimen/text_size_10sp <item >
</style >

<!–Style for text view discounted amount of cell of the product wall–>

<style name="Widget_TextView_Discounted_Amount">
<item name="android:textColor">@color/text_color_discounted_amount</item >
<item name="android:textSize">@dimen/text_size_12sp</item >
</style>

Style for voucher text view

<!–Style for text view voucher code activation–>

<style name="Widget_TextView_Voucher_Activation">
<item name="android:textColor">@android:color/black</item>
<item name="android:textSize">@dimen/text_size_12sp</item>
</style>

<!–Style for text view voucher code expiry date–>

<style name="Widget_TextView_Voucher_Expiry"> 
<item name="android:textColor">@android:color/black</item> 
<item name="android:textSize">@dimen/text_size_12sp</item> 
</style>

<!–Style for text view more click–>

<style name="Widget_TextView_More_Description">
    <item name="android:textColor">@color/description_label_selector</item>
    <item name="android:textSize">@dimen/text_size_12sp</item>
</style>

<!–Style for text view error in case data is not available–>

<style name="Widget_TextView_Data_Error">
    <item name="android:textSize">@dimen/text_size_15sp</item>
    <item name="android:textColor">@color/color_black</item>
    <item name="android:text">@string/str_error_no_data</item>
    <item name="android:gravity">center_vertical</item>
    <item name="android:layout_margin">@dimen/margin_10dp</item>
</style>

<!–Style widget text view merchant details label like merchant name and brand name–>

<style name="Widget_TextView_Label_Merchant_Name_And_Brand">
    <item name="android:textSize">@dimen/text_size_12sp</item>
    <item name="android:textColor">@color/color_black</item>
</style>

<!–Style for text view merchant details text after labels merchant name and brand name–>

<style name="Widget_TextView_Merchant_Details">
    <item name="android:textColor">@color/color_black</item>
    <item name="android:textSize">@dimen/text_size_12sp</item>
</style>

Voucher code dialog style:

To change spinner color you can override following color to your colors.xml file

<color name="color_progress_dialog">#1ABC9C</color>

<!–Style for dialog–>

<style name="Theme_SDK_Dialog" parent="android:Theme.Translucent.NoTitleBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@color/transparent_color</item>
</style>

<!–Style dialog header–>

<style name="Widget_TextView_Dialog_Header">
    <item name="android:textColor">@color/color_black</item>
    <item name="android:textSize">@dimen/text_size_15sp</item>
    <item name="android:gravity">center</item>
</style>

<!–Style for voucher code–>

<style name="Widget_TextView_Dialog_Voucher_Code">
    <item name="android:background">@null</item>
    <item name="android:textColor">@color/color_black</item>
    <item name="android:textSize">@dimen/text_size_15sp</item>
</style>

<!–Style for dialog layout layout–>

<style name="Layout_Dialog_Background">
    <item name="android:layout_marginLeft">@dimen/margin_10dp</item>
    <item name="android:layout_marginRight">@dimen/margin_10dp</item>
    <item name="android:background">@color/color_white</item>
</style>

<!–Style text view dialog message–>

<style name="Widget_TextView_Dialog_Message">
    <item name="android:layout_marginBottom">@dimen/margin_10dp</item>
    <item name="android:layout_marginTop">@dimen/margin_10dp</item>
    <item name="android:textColor">@color/color_black</item>
    <item name="android:textSize">@dimen/text_size_15sp</item>
    <item name="android:gravity">center</item>
</style>