BLOCKv SDK for Android
This is the official BLOCKv SDK. It allows you to easily integrate your own apps into the BLOCKv Platform. It handles a number of operations on your behalf, including:
- Wrapping API endpoints,
- Parsing JSON to native Java models,
- Managing OAuth2 tokens,
- Interacting with the web socket, and
- Visually representing vAtoms using faces. (new)
Requirements
- Android API 19+
- Kotlin
The BLOCKv SDK is dependant on Kotlin, if your version of Android Studio < 3.0 you will need to install it. Go to File | Settings | Plugins | Install JetBrains plugin… and then search for and install Kotlin. If you are looking at the "Welcome to Android Studio" screen, choose Configure | Plugins | Install JetBrains plugin… You'll need to restart the IDE after this completes.
Install and configure the SDK
Add the BLOCKv maven repository and Kotlin plugin to the root-level build.gradle
file:
buildscript {
ext.kotlin_version = '1.2.61'
//...
dependencies {
//...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
//...
repositories {
//...
maven {
url "https://maven.blockv.io/artifactory/BLOCKv"
}
}
}
Next, add the Kotlin plugin and following dependencies to your module Gradle file (usually the app/build.gradle
):
apply plugin: 'kotlin-android' //This should be at the top of the file.
// ...
//
dependencies {
// ...
implementation 'io.blockv.sdk:face:3.0.1'
// Make sure android Studio version is > 3.0 or include the Kotlin Plugin
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version'
}
Finally, add the following uses-permission
element to the manifest:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
To access the BLOCKv SDK in your application code, import the class:
import io.blockv.core.Blockv;
Configure your BLOCKv integration
To configure your integration, create an instance of the BLOCKv SDK.
public class ExampleActivity extends Activity
{
//...
protected void onCreate(Bundle savedInstanceState) {
//...
//BLOCKv instance should be maintained as a singleton
Blockv blockv = new Blockv(this,"Your app id");
}
}
At this point you will need an App Id. See FAQ
Example
Please see the BLOCKv Android Sample for an example on using the BLOCKv SDK.
Dependencies
- nv-websocket-client is used for the web socket.
- RxJava2
Recommendations
We recommend you use Dagger 2, or a similar library, for singleton management for the BLOCKv SDK.
Versioning
This SDK adheres to semantic versioning.
Author
License
BLOCKv is available under the BLOCKv AG license. See the LICENSE file for more info.