mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
docs: android sdk (#5889)
This commit is contained in:
@@ -33,6 +33,10 @@ Integrate the **Formbricks App Survey SDK** into your app using multiple options
|
||||
[Use our iOS SDK to quickly integrate surveys into your iOS applications.](https://formbricks.com/docs/app-surveys/framework-guides#swift)
|
||||
</Card>
|
||||
|
||||
<Card title="Android" icon="android" color="green" href="#android">
|
||||
[Integrate surveys into your Android applications using our native Kotlin SDK.](https://formbricks.com/docs/app-surveys/framework-guides#android)
|
||||
</Card>
|
||||
|
||||
</CardGroup>
|
||||
|
||||
## Prerequisites
|
||||
@@ -409,6 +413,77 @@ Formbricks.cleanup(waitForOperations: true) {
|
||||
| environment-id | string | Formbricks Environment ID. |
|
||||
| app-url | string | URL of the hosted Formbricks instance. |
|
||||
|
||||
|
||||
Now, visit the [Validate Your Setup](#validate-your-setup) section to verify your setup!
|
||||
|
||||
## Android
|
||||
|
||||
Install the Formbricks Android SDK using the following steps:
|
||||
|
||||
### Installation
|
||||
|
||||
Add the Maven Central repository and the Formbricks SDK dependency to your application's `build.gradle.kts`:
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.formbricks:android:1.0.0") // replace with latest version
|
||||
}
|
||||
```
|
||||
|
||||
Enable DataBinding in your app's module build.gradle.kts:
|
||||
|
||||
```kotlin
|
||||
android {
|
||||
buildFeatures {
|
||||
dataBinding = true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```kotlin
|
||||
// 1. Initialize the SDK
|
||||
val config = FormbricksConfig.Builder(
|
||||
"https://your-formbricks-server.com",
|
||||
"YOUR_ENVIRONMENT_ID"
|
||||
)
|
||||
.setLoggingEnabled(true)
|
||||
.setFragmentManager(supportFragmentManager)
|
||||
.build()
|
||||
|
||||
// 2. Setup Formbricks
|
||||
Formbricks.setup(this, config)
|
||||
|
||||
// 3. Identify the user
|
||||
Formbricks.setUserId("user‑123")
|
||||
|
||||
// 4. Track events
|
||||
Formbricks.track("button_pressed")
|
||||
|
||||
// 5. Set or add user attributes
|
||||
Formbricks.setAttribute("test@web.com", "email")
|
||||
Formbricks.setAttributes(mapOf(Pair("attr1", "val1"), Pair("attr2", "val2")))
|
||||
|
||||
// 6. Change language (no userId required):
|
||||
Formbricks.setLanguage("de")
|
||||
|
||||
// 7. Log out:
|
||||
Formbricks.logout()
|
||||
```
|
||||
|
||||
### Required Customizations
|
||||
|
||||
| Name | Type | Description |
|
||||
| -------------- | ------ | -------------------------------------- |
|
||||
| environment-id | string | Formbricks Environment ID. |
|
||||
| app-url | string | URL of the hosted Formbricks instance. |
|
||||
|
||||
## Validate your setup
|
||||
|
||||
Once you’ve completed the steps above, validate your setup by checking the Setup Checklist in the Settings. The widget status indicator should change from this:
|
||||
@@ -420,6 +495,10 @@ To this:
|
||||
|
||||
## Debugging Formbricks Integration
|
||||
|
||||
<Note>
|
||||
The debug mode is only available in the JavaScript SDK and works exclusively in the browser. It is not supported in mobile SDKs such as React Native, iOS, or Android.
|
||||
</Note>
|
||||
|
||||
Enabling debug mode in your browser can help troubleshoot issues with Formbricks. Here’s how to activate it and what to look for in the logs.
|
||||
|
||||
### Activate Debug Mode
|
||||
|
||||
Reference in New Issue
Block a user