Android Partner Integration Framework
caution
The integration libraries and documentation for Yat are still in Alpha. They are not yet feature complete, and there are likely bugs in the implementation.
This guide describes the usage of the Android Yat integration framework for the Yat partners. The integration library provides a simple way for Yat partners to purchase and link Yats from within the partner application.
The Android framework repository contains an example app module named
yat-lib-example
that illustrates the steps below.
#
Requirements- Android OS 7.0+
#
InstallationAdd the JitPack repository in your root
build.gradle
at the end of repositories:allprojects { repositories { // ... maven { url "https://jitpack.io" } }}
Add the dependency:
dependencies { implementation "com.github.yat-labs:yat-lib-android$lastVersion"}
You can find the version you need on Jitpack repository
#
SetupYatIntegration
uses deep links to return from the Yat web application back to the application. The URL scheme of the deep link is agreed upon between the Yat development team and the integration partner. Setup your deep links in your project accordingly.<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="your host here" android:scheme="your scheme here" /> </intent-filter>
Implement the Yat library delegate in your project.
class MainActivity : AppCompatActivity(), YatIntegration.Delegate { // ... override fun onYatIntegrationComplete(yat: String) { /* * Code to run when the integration has completed successfully. */ } override fun onYatIntegrationFailed(failureType: YatIntegration.FailureType) { /* * Code to run when the integration has failed. */ } // ... }
Implement a function that initializes the library with the app-specific constants. The app return link, organization name, and organization key will be delivered to you by the Yat development team.
class MainActivity : AppCompatActivity(), YatIntegration.Delegate { // ... private fun initializeYatLib() { // library configuration val config = YatConfiguration( organizationName = "your organization name", organizationKey = "your organization key", appReturnLink = "your return link" ) // setup the library YatIntegration.setup( config = config, /* * YatIntegration.ColorMode.LIGHT for light mode, * YatIntegration.ColorMode.DARK for dark mode, */ colorMode = YatIntegration.ColorMode.LIGHT, /* * Delegate interface is described below. */ delegate = this ) } // ... }
Add the code that handles deep links.
class MainActivity : AppCompatActivity(), YatIntegration.Delegate { // ... override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) intent.data?.let { deepLink -> YatIntegration.processDeepLink(deepLink) } } // ... }
Usage
Yat is an integration entry point. It contains all tools necessary to configure, style, integrate, and interact with the Yat API.
#
ConfigurationTo configure the integration, you need to pass a new configuration to the YatIntegration.setup
method (please check the Setup section above for more information).
#
StyleYou can change the style (colors, fonts, etc.) of the UI elements used by the framework by overriding Android resources.
#
IntegrationYaIntegration
exposes convenience methods to present a unified UI that allows the user to connect his crypto wallet address to Yat.
To show a simple onboarding overlay, you need to:
YatIntegration.showOnboarding(context: Context, records: List<YatRecord>)
Where records
is a list of YatRecord
structures that will be attached to the user's Yat.
To properly handle the response after the success. you should implement YatIntegration.Delegate. Please check the Setup section above for more information.
#
APIYatIntegration.yatApi
provides all the convenience methods used to directly communicate with the Yat API. Currently, YatIntegration provides methods that handle API calls listed below:
####GET /emoji_id/{yat}/{symbol}
Fetch all records associated with Yat for the provided symbol.
suspend fun lookupEmojiIdWithSymbol(yat: String, symbol: String): LookupEmojiIdWithSymbolResponse
####GET /emoji_id/{yat}/json/{key}
Fetch the key-value store associated with provided Yat. It returns a different data set depending on the provided dataType
.
suspend fun loadValueFromKeyValueStore(yat: String, key: EmojiStoreKey): Response<LoadValueFromKeyValueStoreResponse>