Android Mobile Browser Plugin
Android Browser Plugin SDK Documentation
Version | Details | Date | Author |
---|---|---|---|
1.0.11 | Initial version | 22/07/2022 | SB |
1.2.0 | Introduced show Earnings feature flag | 10/08/2022 | SB |
1.3.0 | Introduced earthmark feature flag | 06/09/2022 | SB |
1.4.0 | Updates to include: - Custom logo - Logic improvements | 07/10/2022 | CPI |
1.5.0 | Fixed an issue causing crash on Android 7 | 11/10/2022 | SB |
1.6.0 | Updates to include: - Fixed an issue when sharing a web page - Fixed an issue for deal activation in the wrong brand - Fixed an issue when the deal popup is shown in domains with no deals - Fixed an issue that was removing the deal popup when scrolling | 17/10/2022 | CPI |
1.7.0 | Fixed an issue on Android 7 | 19/10/2022 | CPI |
1.8.0 | Added cashback configuration | 28/10/2022 | CPI |
1.9.0 | Added charity configuration | 07/11/2022 | CPI |
2.0.0 | Updates to include: - Bug fixes - Added new service status check function | 07/12/2022 | CPI |
2.2.0 | Updates to include: - Settings activation flow more user-friendly | 15/12/2022 | CPI |
2.3.0 | Updates to include: - Spanish, French, German & Korean language support - Network requests bug-fixes - Coupons view bug-fixes | 19/01/2023 | CPI |
2.4.0 | Added Kindred Wallet Sign in | 24/01/2023 | CPI |
2.5.0 | Updates to include: - Added logic improvements | 21/01/2023 | CPI |
2.6.0 | Updates to include: - Added UTM parameters for analytics - Comeback activity bug-fix | 02/03/2023 | CPI |
2.7.1 | Updates to include: - Improved error tracking - Country/currency re-configuration after service starts is now possible - | 22/03/2023 | CPI |
2.7.2 | Updates to include: - Addition of Kindred License Agreement | 02/06/23 | EL |
Getting Started
Follow these instructions to add the Kindred Browser Plugin SDK to an existing application.
For any questions or support with your integration, or to receive your API details, please email [email protected]
Note:
The Android Mobile Browser SDK only works on the Chrome Browser. Support for other browsers is coming soon.
Instructions contained by "[]" need to be adapted for each application.
Instructions contained by "{}" might change on each SDK revision.
-
First, you need to generate an access token from your account;
-
From Github, click your user icon, then click on settings.
-
At the bottom, click Developer Settings
-
Click on Personal access tokens and then click on Generate new token.
-
Add a note, select the expiration time, select the checkbox "read:packages" and click to "Generate token"
-
-
Add the kindred.properties file in the root of your project. This will include authentication for Maven repositories and authentication for the Kindred SDK.
Replace the USERNAME with your Github user name and the TOKEN by the code that has been generated in the previous step
// kindred.properties
ext {
API_URL="https://api-partners.kindred.co"
ASSETS_CDN_URL="https://cdn.kindred.co"
AUTH_CLIENT_ID="[AUTH_CLIENT_ID]"
AUTH_CLIENT_SECRET="[AUTH_CLIENT_SECRET]"
AUTH_SHARED_KEY="[AUTH_SHARED_KEY]"
kindred_sdk_maven_url=https:"maven.pkg.github.com/kindred-app/KindredAndroidPackages"
kindred_sdk_user="USERNAME"
kindred_sdk_secret_key="TOKEN"
}
- Add the SDK’s and dependencies maven repository to settings.gradle file and make sure you apply the "kindred.properties":
// settings.gradle
apply from: "kindred.properties"
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// Kindred SDK Dependency
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/kindred-app/KindredAndroidPackages")
credentials {
username = kindred_sdk_user
password = kindred_sdk_secret_key
}
}
}
}
rootProject.name = "your_app"
include ':app'
- Add the Auth Settings to the defaultConfig in the module build.gradle. This is later passed down to the Kindred SDK during configuration. Make sure you apply the "kindred.properties":
// app/build.gradle
apply from: "../kindred.properties"
...
android {
...
defaultConfig {
...
buildConfigField("String", "API_URL", "\"" + API_URL + "\"")
buildConfigField("String", "ASSETS_CDN_URL", "\"" + ASSETS_CDN_URL + "\"")
buildConfigField("String", "AUTH_CLIENT_ID", "\"" + AUTH_CLIENT_ID + "\"")
buildConfigField("String", "AUTH_CLIENT_SECRET", "\"" + AUTH_CLIENT_SECRET + "\"")
buildConfigField("String", "AUTH_SHARED_KEY", "\"" + AUTH_SHARED_KEY + "\"")
}
...
}
...
}
- Edit the app’s module build.gradle file, and add dependencies with the latest version.
// app/build.gradle
...
implementation 'com.kindred.libraries:browser-sdk:2.6.0'
...
-
Create the Deals Accessibility service class in the app module
Note: find out more about the configuration flags below, in the section Kindred feature configuration
Note: KindredUserConfiguration is deprecated and will be removed in future versions. We suggest the use of the new functions "setUserCountry" & "setUserCurrency" from KidnredFramework.
// DealAccessibilityService.kt
import com.kindred.browser_sdk.KindredAbstractAccessibilityService
import com.kindred.browser_sdk.configuration.*
class DealsAccessibilityService : KindredAbstractAccessibilityService() {
companion object {
val kindredApiConfiguration = KindredApiConfiguration(
urlBase = BuildConfig.API_URL,
clientID = BuildConfig.AUTH_CLIENT_ID,
clientSecret = BuildConfig.AUTH_CLIENT_SECRET,
sharedKey = BuildConfig.AUTH_SHARED_KEY,
cdnUrl = BuildConfig.ASSETS_CDN_URL
)
}
override fun configureService() = KindredAccessibilityServiceConfiguration(
api = kindredApiConfiguration,
user = KindredUserConfiguration(
userCurrency = "CURRENCY_CODE",
userCountry = "COUNTRY_CODE"
),
features = KindredFeaturesConfiguration(
showEarningsConfirmationMessage = true,
earthMarkScoring = true,
showCashbackLabel = true
),
charity = KindredCharityConfiguration(
charityId = "CHARITY_ID",
charityShare = CHARITY_SHARE
)
)
override fun onCreate() {
setUserId("UNIQUE_USER_ID")
setAppIcon(R.drawable."[logo]")
super.onCreate()
}
}
- Setting the user ID (optional)
The default configuration gives each user a unique user ID. If you wish to provide your own user ID or a unique identifier for the user for analytic purposes, you can provide the SDK with you own unique ID as follows:
// DealAccessibilityService.kt
...
override fun onCreate() {
setUserId("UNIQUE_USER_ID")
super.onCreate()
}
...
- Setting a custom icon (optional)
By default, the service will use a Kindred logo but it's possible to set a custom icon by providing the drawable Int in this function:
// DealAccessibilityService.kt
...
override fun onCreate() {
setAppIcon(R.drawable."[logo]")
super.onCreate()
}
...
- Setting an activity to comeback after service activation (optional) (Min Android 7)
You can use this function to set a comeback intent. After the service is activated by the user, they will get returned to the activity if the set intent automatically:
// DealAccessibilityService.kt
...
override fun onCreate() {
setComebackActivity(Intent(this, YOUR_ACTIVITY_NAME::class.java))
super.onCreate()
}
...
- Add the accessibility service xml file in the res/xml folder.
// accessibilityservice.xml
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/accessibility_service_description"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFlags="flagDefault|flagReportViewIds|flagRetrieveInteractiveWindows"
android:accessibilityFeedbackType="feedbackVisual"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"
android:settingsActivity="com.example.android.accessibility.ServiceSettingsActivity"
/>
- Add permissions to the AndroidManifest.xml file
// AndroidManifest.xml
...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
...
- Add accessibility service to the AndroidManifest.xml file
// AndroidManifest.xml
...
<application
...
<service
android:name="com.kindred.browsersdk.DealsAccessibilityService"
android:canRetrieveWindowContent="true"
android:exported="true"
android:label="@string/accessibility_service_label"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibilityservice" />
</service>
...
</application>
...
- Add string values to the res/values/strings.xml (Note, you can change these values as applicable)
// strings.xml
...
<string name="accessibility_service_description">By allowing the Accessibility Permission, you permit “App Name” to access data about your URLs. We do this to enable you to save money when you are shopping on your favourite brands, coupon codes will pop up at checkout, helping you to save!</string>
<string name="accessibility_service_label">Kindred</string>
...
Kindred Framework
KindredFramework is an object class we expose to facilitate some functionalities related to the service.
isAccessibilityServiceEnabled
This function will return the current status of the service, a boolean indicating if the service is currently running or not.
val serviceStatus = KindredFramework.isAccessibilityServiceEnabled(context)
openAccessibilityServiceSettings
This function will open the accessibility settings of the service for its activation and will display a toast message with the received text.
KindredFramework.openAccessibilityServiceSettings(context, "INCLUDE YOUR TEXT HERE")
This toast message is a tiny popup at the bottom of the screen and it's centred. It will disappear after a fraction of a second.
openKindredWallet
This functions wil receive the context, the kindredApiConfiguration companion object that was created in the service and a callback. It will open the wallet sign in web page in the default browser.
The callback will receive one of three states: _SUCCEED, NO_AUTH (No authentication was detected during the process), ERROR (Something else went wrong)
KindredFramework.openKindredWallet(this, DealsAccessibilityService.kindredApiConfiguration) {
Log.d("kk", "$it")
}
setUserCountry
This function allows you to override the country code of the initial service configuration or add one if none was specified at the service start.
KindredFramework.setUserCountry("COUNTRY_CODE", context)
setUserCurrency
This function allows you to override the currency code of the initial service configuration or add one if none was specified at the service start.
KindredFramework.setUserCurrency("CURRENCY_CODE", context)
Kindred feature configuration
What is "Show Earnings" feature flag?
If you would like us to popup to the user whenever they've made any cash back or donated to a cause, you can set this feature flag on when setting up the configuration on the DealsAccessibilityService.
What is "EarthMark" feature flag?
Earthmark have developed a rating system to show how "green" retailers really are. Earthmark's rating system will now be highlighted within the Kindred technology so partners can help their users make more informed choices to shop sustainably.
What is "Show Cashback label" feature flag?
You can turn on/off the cashback label feature flag. Having it on means that when we detect a cashback deal, the user will be notified through the popups with text indicating how much cashback they would be earning. Having the feature off means that there will not be any reference to cashback or cashback amount instead, will reference a deal.
Feature flag off
Feature flag on
Kindred SDK Size
What's the size of our SDK in your project and APK?
Adding the Kindred SDK to a sample project adds an extra 0.71 MB to the total APK size
Before SDK:
- Project size: 35.4 MB
- APK size: 5.25 MB
After SDK:
- Project size: 46.1 MB
- APK size: 5.96 MB
License Agreement: https://event.kindred.co/licensing-terms-and-conditions
Updated about 9 hours ago