Skip to content

Commit 86af64d

Browse files
authored
Merge pull request #18 from segmentio/firebase-kotlin
DOC-322 Setting up Firebase with Kotlin
2 parents 399aef0 + 5939cce commit 86af64d

File tree

1 file changed

+36
-0
lines changed
  • src/connections/destinations/catalog/firebase

1 file changed

+36
-0
lines changed

src/connections/destinations/catalog/firebase/index.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,42 @@ If you use Segment's React Native source library, you must explicitly bundle the
114114

115115
<!-- LR Mar 2021: We didn't use the react-dest include here because Firebase needs the extra build.gradle step.-->
116116

117+
## Setting up Firebase with Analytics-Kotlin
118+
If you're using the [Analytics-Kotlin library](/docs/connections/sources/catalog/libraries/mobile/kotlin-android), follow these steps to set up Firebase with Analytics-Kotlin:
119+
1. In your top-level `build.gradle` file add these lines:
120+
```kotlin
121+
buildscript {
122+
...
123+
repositories {
124+
google()
125+
}
126+
dependencies {
127+
...
128+
classpath 'com.google.gms:google-services:4.3.5'
129+
}
130+
}
131+
```
132+
2. In your app-module `build.gradle` file add these lines:
133+
```kotlin
134+
...
135+
plugins {
136+
id 'com.google.gms.google-services'
137+
}
138+
139+
dependencies {
140+
...
141+
implementation platform('com.google.firebase:firebase-bom:28.2.1')
142+
implementation 'com.google.firebase:firebase-analytics-ktx'
143+
}
144+
```
145+
3. Copy the [FirebaseDestination.kt](https://github.com/segmentio/analytics-kotlin/blob/main/samples/kotlin-android-app-destinations/src/main/java/com/segment/analytics/destinations/plugins/FirebaseDestination.kt) file into your project's codebase.
146+
4. Copy your `google-service.json` file to your app-module.
147+
5. Go to your project's codebase and add these lines where you intialize the analytics client:
148+
```kotlin
149+
val Firebase = FirebaseDestination()
150+
analytics.add(Firebase)
151+
```
152+
117153
## Identify
118154
119155
When you call `identify` Segment will map to the corresponding Firebase Analytics calls:

0 commit comments

Comments
 (0)