In this article, you will find step-by-step instructions to add Connectif Mobile SDK to your Android project. This begins the integration of your Mobile App with Connectif, once you have reviewed that you meet the prerequisites to perform it.
1. Requirements to add Connectif Mobile SDK to your Android project
- You will need to have your Mobile App integration activated in Connectif to access the integration configuration for your key. You can check our implementation guide.
- Developed as an Android library.
- Minimum supported version Android 5.0 (Level 21).
- Implemented in the app using Firebase Cloud Messaging for receiving push notifications.
2. How to add Connectif Mobile SDK to your Android project
2.1. Add the SDK
Add the SDK dependency to your build.gradle (Module: app) file.
Kotlin
implementation("ai.connectif:sdk:1.0.1")
Groovy
implementation 'ai.connectif:sdk:1.0.1'
Click on the Sync Now option in the top toolbar to sync the Gradle file.
2.2. Initialize the Connectif SDK
The best place to initialize our SDK is in the onCreate callback of the Application Class.
Optionally, to obtain the email of users who registered or logged in before implementing the Connectif Mobile SDK, we will send the user's email when initializing the SDK. The email must meet the following requirements:
- A valid email must have a username, followed by @, a domain, and an extension, with no spaces or special characters.
- A maximum of 200 characters.
Example of the email:
class SampleApp : Application() {
override fun onCreate() {
super.onCreate()
Connectif.init(
context = applicationContext,
apiKey = "YOUR_API_KEY",
"usermail@example.com"
)
}
}
3. Additional Configurations
Remember that when initializing the SDK, you can define some values using the ConnectifConfig parameter in Connectif.initialize().
3.1. Icon
By default, this is the icon assigned to our push notifications:
ic_default_notification
If you want, you can customize it by specifying the resource in the pushSmallIcon property of ConnectifConfig when initializing the SDK. Remember that for it to display correctly, it should only contain white and transparent colors.
3.2. Notification Channel
From Android 8 onwards, it is mandatory to create a channel to display notifications. By default, we assign the name "Default Channel" and the channel ID "connectif_channel" to the notifications shown by Connectif.
You can specify your custom channel name and ID using the pushChannelName and pushChannelId properties of ConnectifConfig when initializing the SDK.
3.3. Log
You can define the logLevel, i.e., the level of logs we want to show (default: LogLevel.NONE). Each level includes the logs from the previous level, so the INFO level will display all logs.
- NONE: Disables all logs.
- ERROR: Logs only errors.
- WARN: Logs warnings and errors .
- INFO: Logs informational messages, warnings, and errors.
4. Implementing User Tracking
Once you have configured the initialization, you can begin tracking the user by implementing the various notifications.
- Notify page visit event
- Notify product visit event
- Notify purchase event
- Notify search event
- Notify cart information
- Notify contact information
- Notify newsletter subscription
- Notify login event
- Notify registration event
- Notify custom event
Keep learning!
To take full advantage of your Connectif account, we recommend continuing with the following articles:
- Complete guide to integrating Connectif with your Mobile App, for an in-depth understanding of all the changes in this integration.
- Firebase Cloud Messaging Setup, to activate sending and receiving push notifications via the Android Mobile SDK.
- iOS SDK Get Started, to add Connectif Mobile SDK to your iOS project.
- Apple Push Notifications Service Setup, to activate sending and receiving push notifications via the iOS Mobile SDK.