init
Initialize the application using the configure API.
Method signature
The following code shows the method signature of the configure API:
copy
fun init(application: Application, configuration: Configuration?,callBack: IntiCallBack? = null)Request parameters
Field | Data type | Description |
application | Application | Provides necessary parameters for global initialization |
configuration | Provides optional and additional SDK configurations | |
callBack | IntiCallBack | Monitors SDK initialization success/failure |
Response parameters
N/A
Exceptions
Error Code | Error message |
1001 | Initialization failed because the configuration file could not be read. Please check if the assets/ASAPLocalConfiguration.json file exists. |
1002 | A system error has occurred. |
1003 | Initialization failed because the ASAP configuration was not found. |
Samples
Java
copy
Configuration config = new Configuration.Builder()
.setFetchUserId(new IFetchUserId() {
@Nullable
@Override
public String fetchUserId(@NonNull Business business) {
return "100";
}
})
.setDebug(false)
.setASAPConfiguration(new ASAPConfiguration("https://xxx", "https://xxx", "templates/ASAPLocalTemplates.json"))
.setRpcSingerMode(new RPCSignerMode.Helper.Helper(appKey, authCode))
.build();
ComponentManager.Companion.init(getApplication(), config, new IntiCallBack() {
@Override
public void onSuccess() {
Log.d("asap-sdk", "init success");
}
@Override
public void onFailure(int i, @NonNull String s, @Nullable Throwable throwable) {
Log.d("asap-sdk", "onFailure: code=" + i + ",msg" + s);
}
});
Kotlin
copy
val config = Configuration.Builder()
.setFetchUserId(object : IFetchUserId {
override fun fetchUserId(business: Business): String {
return "your user id"
}
})
.setDebug(false)
.setASAPConfiguration(
ASAPConfiguration(
"https://xxx",
"https://xxx",
"templates/ASAPLocalTemplates.json"
)
)
.setRpcSingerMode(RPCSignerMode.Helper(appKey, authCode))
.build()
//No callback
//ComponentManager.init(application,config)
ComponentManager.init(application,config, object : IntiCallBack {
override fun onSuccess() {
Log.d("asap-sdk","init success")
}
override fun onFailure(code: Int, msg: String,throwable: Throwable?) {
Log.d("asap-sdk","init failed :$code,message:$msg")
}
})