3. Configuration
To initialize the Sentiance SDK, you first need to prepare a configuration object of type SdkConfig that includes your Sentiance appID and secret key. Head over to the apps section of your developer account to grab these.
Depending on your app's configuration and OS version, the SDK may need to start a foreground service every now and again. You must therefore pass a notification that can be used by the service. In the next section, you'll find a handy notification creation method.
Please read our notification management section to learn how to build user friendly notifications.
Create an SdkConig object as follow:
SdkConfig config = new SdkConfig.Builder(APP_ID, SECRET, notification)
In the above example, we hard-code the the appID and secret key for testing purposes. However, this is not secure and can lead to leaked credentials. In your own app, load these credentials from a secure source such a remote server, and store them securely on the device.
The SdkConfig accepts a userLinker which is responsible for handling user linking. The linker is invoked by the SDK when creating a Sentiance user (during the first initialization) to give you a chance to link your app's user to the Sentiance user. If linking succeeds, this linker does not get invoked during subsequent SDK intializations, unless the SDK gets reset.
MetaUserLinker userLinker = new MetaUserLinker() {
public boolean link(String installId) {
// Supply the 'installId' to your server, which should then initiate
// a user linking request with the Sentiance backend.
return requestLinking(installId); // return true if user linking succeeds
The above implementation expects synchronous execution. Alternatively, you can use MetaUserLinkerAsync which is the async variant of the linker. You then notify the SDK about the linking result by calling onSuccess() or onFailure().
You can learn more about user linking here. To see what other SDK configuration options are available, see SdkConfig.Builder.
Copy link