Releases: squadded/public-android-sdk
v0.1.0
ec6f5a61dc88e8a441bcdb391b2b33d1aa59bf9e
Singleton
The co.squadded.sdk.SquaddedSDK
object is a singleton which you must initialize once with:
static init(String merchantId, String siteUrl, String siteTitle)
merchantId
: your ID which was assigned to you by SquaddedsiteUrl
: the root URL of your merchant sitesiteTitle
: the short description of your brand or site, which you wish to be used in the Share actions
Instance
You may obtain the singleton instance with static SquaddedSDK.getInstance()
.
Display/Close the widget
You can pull open the Squadded Widget screen, by calling openWidget(ViewGroup root)
:
root
: the parentViewGroup
into which the screen will be added.
You may close the widget programmatically by invoking close()
.
Typically, you should monitor for the Back action and close the Widget accordingly, in order to offer a seamless user experience.
Add an item to Wishlist
You can programmatically request to send an article to the Squadded Wishlist, by calling addToWishlist(ViewGroup root, Item item)
:
-
ViewGroup root
: the parent container for the widget, in case it is not already open. -
Item item
: an instance ofco.squadded.sdk.SquaddedSDK.Item
containing the following properties:String itemId
: the unique ID of your article in your own databaseString currency
: the textual symbol to use as the currency (eg.$
,EUR
, etc.)String img
: the URL of the article's image in your WebsiteString title
: the name/title/description of the productString url
: the URL of the product page, in your Websiteint price
: the price after discount, multiplied by 100 (eg: $9.99 will be expressed as(int) 999
int origPrice
: the price before discount, multiplied by 100.
Listeners
You can be informed when a user taps on a product inside the Widget, by registering this handler:
setOnViewProduct(OnViewProduct onViewProduct)
:
-
co.squadded.sdk.SquaddedSDK.OnViewProduct onViewProduct
: the callback, according to this interface:void onViewProduct(String productId, String url)
where :
String productId
: your own item IDString url
: the URL of the product's page in your own site