Kotlin Apps
For Kotlin applications using Jetpack Compose or traditional Views:1. Create Application Class
Create or update yourApplication class:
import android.app.Application
import com.zixflow.sdk.Zixflow
import com.zixflow.sdk.ZixflowConfigBuilder
import com.zixflow.sdk.core.util.ZixflowLogLevel
import com.zixflow.messaginginapp.MessagingInAppModuleConfig
import com.zixflow.messaginginapp.ModuleMessagingInApp
import com.zixflow.messagingpush.ModuleMessagingPushFCM
import com.zixflow.location.ModuleLocation
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Zixflow SDK
val config = ZixflowConfigBuilder(
applicationContext = this,
apiKey = "YOUR_API_KEY"
)
.autoTrackDeviceAttributes(true)
.autoTrackActivityScreens(true)
.trackApplicationLifecycleEvents(true)
.logLevel(ZixflowLogLevel.DEBUG)
// Add push notifications module (optional)
.addZixflowModule(ModuleMessagingPushFCM())
// Add in-app messaging module (optional)
.addZixflowModule(
ModuleMessagingInApp(
config = MessagingInAppModuleConfig.Builder().build()
)
)
// Add location tracking module (optional)
.addZixflowModule(ModuleLocation())
.build()
Zixflow.initialize(config)
}
}
2. Register Application in AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name">
<!-- Your activities -->
</application>
</manifest>
3. Replace Configuration Values
- YOUR_API_KEY: Your Zixflow API key (from Zixflow dashboard)
Java Apps
For Java-based applications:1. Create Application Class
import android.app.Application;
import com.zixflow.sdk.Zixflow;
import com.zixflow.sdk.ZixflowConfig;
import com.zixflow.sdk.ZixflowConfigBuilder;
import com.zixflow.sdk.core.util.ZixflowLogLevel;
import com.zixflow.messaginginapp.MessagingInAppModuleConfig;
import com.zixflow.messaginginapp.ModuleMessagingInApp;
import com.zixflow.messagingpush.ModuleMessagingPushFCM;
import com.zixflow.location.ModuleLocation;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Configure and initialize Zixflow SDK
ZixflowConfig config = new ZixflowConfigBuilder(
this, // applicationContext
"YOUR_API_KEY"
)
.autoTrackDeviceAttributes(true)
.autoTrackActivityScreens(true)
.trackApplicationLifecycleEvents(true)
.logLevel(ZixflowLogLevel.DEBUG)
.addZixflowModule(new ModuleMessagingPushFCM())
.addZixflowModule(
new ModuleMessagingInApp(
new MessagingInAppModuleConfig.Builder().build()
)
)
.addZixflowModule(new ModuleLocation())
.build();
Zixflow.initialize(config);
}
}
2. Register in AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name">
<!-- Your activities -->
</application>
</manifest>