# VoIP calls on Android

Pushwoosh supports VoIP-style call notifications for Android using the `pushwoosh-calls` module. This enables native call UI and lifecycle management using Android's telecom stack.


## 1. Add the `pushwoosh-calls` module

Make sure to include the `pushwoosh-calls` dependency in your project.

**Gradle:**

```groovy
dependencies {
    implementation 'com.pushwoosh:pushwoosh-calls:<latest-version>'
}
```

Replace `<latest-version>` with the current version from [Maven Central](https://mvnrepository.com/artifact/com.pushwoosh/pushwoosh-calls).


## 2. Request call permissions

Request required permissions at runtime using the helper function:

```java
import com.pushwoosh.calls.PushwooshCallSettings;

PushwooshCallSettings.requestCallPermissions();
```

> This handles requesting permissions like `READ_PHONE_NUMBERS`, necessary for proper call handling.



## 3. Implement `CallEventListener` and register it in the Manifest

To handle incoming calls and events, implement the `CallEventListener` interface in your app.

#### Java example

```java
public class DemoCallEventListener implements CallEventListener {

    @Override
    public void onAnswer(@NonNull PushwooshVoIPMessage voIPMessage, int videoState) {
        // implement this method to navigate to your in-call UI 
        Intent intent = new Intent(context, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }

    @Override
    public void onReject(@NonNull PushwooshVoIPMessage voIPMessage) {
        // override this method to handle dismissed calls 
    }

    @Override
    public void onDisconnect(@NonNull PushwooshVoIPMessage voIPMessage) {
        // override this method to handle disconnected calls 
    }

    @Override
    public void onCreateIncomingConnection(@Nullable Bundle payload) {
        // this is the earliest point when call notification payload is accessible in your app,
        // use it to prepare your app UI for user interactions with call notifications
    }

    @Override
    public void onCallAdded(@NonNull PushwooshVoIPMessage voIPMessage) {
        // extension method of InCallService, provides customization options for paired Wearable devices
    }

    @Override
    public void onCallRemoved(@NonNull PushwooshVoIPMessage voIPMessage) {
        // extension method of InCallService, provides customization options for paired Wearable devices
    }
}
```

#### AndroidManifest.xml

Declare your listener class using a `<meta-data>` tag:

```xml
<meta-data
    android:name="com.pushwoosh.CALL_EVENT_LISTENER"
    android:value="com.pushwoosh.demoapp.DemoCallEventListener" />
```


## 4. Configure call settings (optional)

Use `PushwooshCallSettings` to fine-tune call behavior, sounds, and display settings.

#### Example usage

```kotlin
import com.pushwoosh.calls.PushwooshCallSettings

PushwooshCallSettings.setPhoneAccount("com.pushwoosh.voip")
PushwooshCallSettings.setPhoneAccountHandle("PushwooshCallHandle")
PushwooshCallSettings.setIncomingCallChannelName("Incoming Calls")
PushwooshCallSettings.setOngoingCallChannelName("Ongoing Calls")
PushwooshCallSettings.setCallSound("custom_ringtone.mp3")
```


## Related links

- [Pushwoosh Android SDK Overview](/developer/pushwoosh-sdk/android-sdk/)
- [Pushwoosh Call Plugin Source](https://github.com/Pushwoosh/pushwoosh-android-sdk)
- [TelecomManager (Android Docs)](https://developer.android.com/reference/android/telecom/TelecomManager)