Configurable properties of SDK initialize
Initial Configuration: default activity and log debug
You can customize the init configuration with the following parameters:
- setLogDebug: set the debug level on Log to show: Debug, info, warning or error
- setDefaultActivity: The Activity by default is the initial screen of your app that is launched when a user clicks on a notification that does not have a deeplink. It is also the point where you should initialize the SDK.
Set default activity
To set this value, you don't have to set a string name, you have to set the name of the class as the following example
You can see an example in this code block:
Configuration.Builder config = new Configuration.Builder("YOUR_APPKEY","YOUR_SENDER_ID")
.setLogDebug(LogLevel.DEBUG)
.setDefaultActivity(MainActivity.class.getName())
.build();
Indigitall.init(config, new InitCallback(context){...})
- setAutoRequestPushPermission: to request permission automatically. Default value is true.
Configuration.Builder config = new Configuration.Builder("YOUR_APPKEY","YOUR_SENDER_ID")
.setAutoRequestPushPermission(false)
.build();
Indigitall.init(config, new InitCallback(context){...})
[...]
/* To request push permission*/
ServiceUtils.checkPushPermission(context);
[...]
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>,
grantResults: IntArray
) {
Indigitall.onRequestPermissionsResult(this, requestCode, permissions, grantResults)
}
- setAlwaysLaunchOnInit: on the first time initializing, callback onIndigitallInitialized is executed. Default value is false.
Configuration.Builder config = new Configuration.Builder("YOUR_APPKEY","YOUR_SENDER_ID")
.setAlwaysLaunchOnInit(true)
.build();
Indigitall.init(config, new InitCallback(context){...})
Callbacks offered by the SDK
Our SDK offers various callbacks that help you have greater control of the execution flow and implement custom behaviors.
To subscribe to these callbacks you have to:
- Instantiate the InitCallBack object and pass it as the third parameter of the init method.
- Override the methods that the InitCallBack class implements.
Indigitall.init(context, config, new InitCallBack(context){
@Override
public void onIndigitallInitialized(Permission[] permissions, Device device) {}
@Override
public void onNewUserRegistered(Device device) {}
@Override
public void onErrorInitialized(int errorId, String message, String description) {}
});
Initialized SDK
The method onIndigitallInitialized of the InitCallBack object will execute when the SDK finishes initializing and the device is ready to receive notifications from indigitall.
Receive as parameter:
- An array of Permission objects. The first item is the status of the claims permission. The second item is the status of the locate permission.
- A Device object with the information associated with the device.
Here is an example that prints logs about the status of permissions and device information.
Indigitall.init(context,config, new InitCallBack(context){
@Override
public void onIndigitallInitialized(Permission[] permissions, Device device) {
super.onIndigitallInitialized(permissions, device);
Log.d("Push Permission: ", permissions[0].toString());
Log.d("Location Permission: ", permissions[1].toString());
Log.d("Device: ", device.toString());
}
});
New registered device
The method onNewUserRegistered of the InitCallBack object will be executed when the device has been registered for the first time, that is, in the first execution of the app after being installed.
It receives as a parameter the Device object with the information associated with the device.
Indigitall.init(context, config, new InitCallBack(context){
@Override
public void onNewUserRegistered(Device device) {
super.onNewUserRegistered(device);
Log.d("Device: ", device.toString());
}
});
An error has occurred
The onErrorInitialized method of the InitCallBack object will be executed only if an error occurs during the initialization of the SDK.
It receives the description of the error as a parameter.
Indigitall.init(context, config, new InitCallBack(context) {
@Override
public void onErrorInitialized(int errorId, String message, String description) {
super.onErrorInitialized(errorId, message, description);
Log.d("Error on Indigitall.init: ", message);
}
});