Environment Build
1. Overview
This article mainly introduces some configurations that need to be added to your project before integrating Lumi SDK, and obtains the necessary parameters for SDK initialization.
2. Preconditions
- Confirm completion Preparation
- Make sure you have installed Android Studio and configured JDK, Android SDK and other development environments. For details, please go to Android Developer Official Website
3. Add Dependencies
3.1 Compilation environment requirements
Supported version
Parameter | Version number | Describe |
---|---|---|
minSdkVersion | 21 | Android 5 |
targetSdkVersion | 33 | Android 13 |
3.2 Open Android Studio
3.3 Edit build.gradle
under root directory
Note: The access to the maven warehouse requires an account and password, and you need to contact the business to obtain it.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
//Aqara maven warehouse
maven {
url 'https://public-maven.aqara.com/repository/lumi-release/'
credentials {
username = 'maven_username'
password = 'maven_password'
}
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
//Aqara Android initialization plug-in
classpath 'com.lumi.plugin:module-init:2.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven {
url 'https://public-maven.aqara.com/repository/lumi-release/'
credentials {
username = 'maven_username'
password = 'maven_password'
}
}
}
}
3.4 Edit build.gradle
in the app
directory
plugins {
id 'com.android.application'
}
//Aqara unified initialization plug-in
apply plugin: 'lumi-module-init'
android {
}
dependencies {
//Aqara unified initialization dependencies, pay attention to use the latest version
implementation 'com.lumi.external:core:2.1.9'
}
3.5 Support AndroidX
Add support for AndroidX in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
3.6 Permission Statement
4. Initialization
4.1 O btain the necessary parameters for SDK initialization
4.1.1 Get AppId and AppKey
See documentation Preparation
4.1.2 Get other necessary parameters
According to different account authorization methods, the acquisition methods are also inconsistent. For details, please refer to Authorization Management
Generally speaking, the virtual account authorization mode is used most of the time, that is, the third-party app needs to request its own cloud platform to obtain relevant parameters:
4.2 SDK Initialization
Integrate various business SDKs on the Aqara Android side, usually only need to be initialized uniformly through LumiCoreManager
, other business SDKs usually do not need to be initialized separately.
4.2.1 Perform Unified Initialization
Initialize interface call
final LumiCoreManager.LumiCoreSDKConfig config =
new LumiCoreManager.LumiCoreSDKConfig.Companion.Builder()
.baseUrl("host")
.baseH5Url("h5Url")
.baseImageUrl("imageUrl")
.appId("appId")
.appKey("appKey")
.clientId("clientId")
.sdkChannel("sdkChannel")
.userInfo(new ILumiUserInfo() {
@Nullable
@Override
public String getUserId() {
return "userId";
}
@Nullable
@Override
public String getUserToken() {
return "userToken";
}
@NonNull
@Override
public String getArea() {
return "area";
}
@NonNull
@Override
public String getLanguage() {
return "language";
}
@NonNull
@Override
public String getSupportDeviceArea() {
return "area";
}
})
.build();
//True means to open the debug log, false otherwise
//Note: calling the init method multiple times is invalid. If you need to update the parameters later, please call the update method.
LumiCoreManager.Companion.getInstance().init(this, true, config);
Parameter Description
Field | Type of data | Description | Access channel |
---|---|---|---|
appId | String | App unique identification | Aqara Developer Platform |
appKey | String | App unique identification | Aqara Developer Platform |
clientId | String | App push unique identifier | Interface acquisition, please refer to Aqara Developer Platform |
baseUrl | String | The domain name requested by the SDK | Interface acquisition, please refer to Aqara Developer Platform |
baseH5Url | String | The H5 link requested by the SDK | Interface acquisition, please refer to Aqara Developer Platform |
baseImageUrl | String | Image cdn address requested by the SDK | Interface acquisition, please refer to Aqara Developer Platform |
sdkChannel | String | Channel ID | Project identification, which affects some business logic processing, just fill in the project name |
userId | String | Unique user ID | Interface acquisition, please refer to Aqara Developer Platform |
userToken | String | User access token | Interface acquisition, please refer to Aqara Developer Platform |
area | String | App Location | The default value is CN |
language | String | App current language | The default value is zh |
supportDeviceArea | String | The area where the device is connected to the network | The default value is CHN |
Note: area and supportDeviceArea, some area codes are different
Language value
The language parameter will affect the SDK and the cloud to return to the multi-language type.
Value | Describe | Description |
---|---|---|
zh | Simplified Chinese | Default |
zh_TW | Taiwan Traditional | / |
zh_HK | Hong Kong Traditional | / |
en | English | / |
ko | Korean | / |
ru | Russian | / |
de | German | / |
it | Italian | / |
fr | French | / |
es | Spanish | / |
Note: This value only affects the multilingual information dynamically obtained, such as cloud interfaces, configuration files, etc. The multilingual used by the SDK itself (stored in strings.xml) follows the multilingual of the host App.
Area value
The area parameter will affect the business logic of the cloud interface, and some services may be unavailable in some areas.
Value | Describe | Description |
---|---|---|
CN | China mainland | Default |
HMT | Hong Kong, Macau, Taiwan of China | / |
US | America | / |
EU | Europe | / |
RU | Russia | / |
SEA | Southeast Asia | / |
KR | Korea | / |
JP | Japan | / |
AU | Italy | / |
ME | Middle East | / |
AF | Africa | / |
OTHER | Other areas | / |
SupportDeviceArea value
The supportDeviceArea parameter will affect the device network configuration. (Some devices can only be activated and used in specific regions)
Value | Describe | Description |
---|---|---|
CN | China mainland | Default |
HMT | Hong Kong, Macau, Taiwan of China | / |
US | America | / |
EU | Europe | / |
RU | Russia | / |
SEA | Southeast Asia | / |
KR | Korea | / |
JP | Japan | / |
AU | Italy | / |
ME | Middle East | / |
AF | Africa | / |
OTHER | Other areas | / |
4.2.2 Update user information
If you need to switch users, or the Token is invalid, you need to request the interface again. Please refer to Aqara Developer Platform, and update the SDK user information.
Update user information interface call
LumiCoreManager.Companion.getInstance()
.updateUserConfig(new ILumiUserInfo() {
@Nullable
@Override
public String getUserId() {
return "userId";
}
@Nullable
@Override
public String getUserToken() {
return "userToken";
}
@NonNull
@Override
public String getArea() {
return "area";
}
@NonNull
@Override
public String getLanguage() {
return "lang";
}
@NonNull
@Override
public String getSupportDeviceArea() {
return "area";
}
});
5. Push
The SDK itself does not have the ability to obtain cloud push, and needs to rely on the push from the host App. For details, please check Message Push
5.1 Subscribe Push
LumiCoreManager.getInstance().rePushClientId("clientId")
Parameter Description
Field | Type of data | Description | Access channel | example |
---|---|---|---|---|
clientId | String | App push unique identifier | Interface acquisition, please refer to Aqara Developer Platform | HOST+"Any string"(Up to 64 characters, Suggest concatenating token) |
5.2 Forward push
When the third-party app receives the push about the Aqara device, it can forward it to the SDK.
LumiCorePushManager.getInstance().onMessage("content")
Be careful not to transparently pass the entire message body to the SDK, the SDK only needs the string starting with LUMI@
Parameter Description
Field | Type of data | Description | Access channel |
---|---|---|---|
content | String | Push Message | App itself obtains |
5.3 Push message format
Just pass content
to the SDK
{
"sequenceNo": "202106031107",
"osType": "android",
"content": "LUMI@eyJ0eXBlIjoicmVzX3N1YnNjcmliZSIsInJlc3VsdCI6eyJ0aW1lU3RhbXAiOjE2MjMwNjUwNjA5NzYsImF0dHJDaGFubmVsIjoxLCJzb3VyY2UiOiI0LCwxNjIzMDY1MDYwNzgxLDlmMzgyMTIwNjczMTI0ZDI5N2VmNjI0MV9lOTE3ZjE0MDBhNTIyNDk1LjU0NTU4MTgyNTk4MDg5MTEzNywsIiwiYXR0ciI6IjE0LjcuODUiLCJ2YWx1ZSI6IjEyOTE4MTExNTIiLCJzdWJqZWN0SWQiOiJsdW1pMS41NGVmNDRjOTExNjUiLCJpZGVudGlmeUlkIjoiSE9TVDA0YTZkYzAzNzMyNTM3NTBiMzIyMzMxOGVhMGQ1ZmVhMjk0YSIsInB1c2hUeXBlIjoicmVzX3N1YnNjcmliZSJ9LCJjb2RlIjowfQ==",
"token": "04a6dc0373253750b3223318ea0d5fea294a"
}