# Android SDK

Bird Android SDK is a single integration point to bring the power of BirdCRM in building connected user experience to your application.

Using Bird Android SDK, you get access to:

* Collect contacts
* Send push notifications

Integrating Bird Android SDK into your application consists of the following steps:

* Step 1: Add Bird Android SDK dependency
* Step 2: Set Application Key
* Step 3: Add permissions
* Step 4: Push Notifications
  * Add Firebase credentials file
  * Add `BirdFirebaseMessagingService`

### Step 1: Add Bird Android SDK dependency

Add the `com.bird:android-sdk` dependency to your app’s `build.gradle`.

```
dependencies {
  implementation("com.bird:android-sdk:+")
}
```

Make sure to run Gradle Sync to build your project using the newly added dependency.

### Step 2: Set Application Key

Add a new string to your app's `strings.xml` with the name `com_bird_application_key`. You can get the value of this application key from "**Bird Dashboard / Preferences / Applications**".

```xml
<resources>
    <string translatable="false"  name="com_bird_application_key">YOUR_APPLICATION_KEY</string>
</resources>
```

### Step 3: Add permissions

No additional permissions need to be set in `AndroindManifest.xml`. The user will be asked to give Push Notification permissions in runtime.

### Step 4: Push Notifications

### Firebase

#### Add Firebase credentials file

Get `google-service.json` file from your Firebase project and add it to your android application. See more information [here](https://firebase.google.com/docs/android/setup#add-config-file)

And add the `com.google.gms.google-services` plugin to both your top-level `build.gradle` and your app’s `build.gradle`.

```gradle
// Inside the top-level build.gradle
plugins {
    id("com.google.gms.google-services") version "4.4.0" apply false
}
```

```gradle
// Inside app's build.gradle
plugins {
    id("com.google.gms.google-services")
}
```

Make sure to run Gradle Sync to build your project using the newly added plugin.

#### Add BirdFirebaseMessagingService

Add the following `com.bird.BirdFirebaseMessagingService` as a `service` inside `AndroindManifest.xml`.

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application>

        <!-- START: Add This Part -->
        <service 
            android:name="com.bird.BirdFirebaseMessagingService"
            android:exported="false"
            tools:ignore="Instantiatable">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
        </service>
        <!-- END -->

    </application>

</manifest>
```

<details>

<summary>Advanced</summary>

In case you need to use your own `FirebaseMessagingService`, you can inherit `BirdFirebaseMessagingService`, calling the super methods and customizing the rest as you need.

```kotlin
class MyFirebaseMessagingService : BirdFirebaseMessagingService() {
  override fun onMessageReceived(remoteMessage: RemoteMessage?) {
    super.onMessageReceived(remoteMessage)
    
    // Do anything else you need.
  }
}
```

Then add your class `MyFirebaseMessagingService` as a `service` inside `AndroindManifest.xml`.

```xml
<application>

    <!-- START: Add This Part -->
    <service 
        android:name="MyFirebaseMessagingService"
        android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
    </service>
    <!-- END -->

</application>
```

</details>

### Examples

You can find examples and report issue on the public repository [messagebird/android-sdk](https://github.com/messagebird/android-sdk).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bird.com/api/client-sdks/sdk-integration/android-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
