ข้ามไปยังเนื้อหา

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

Anchor link to

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

Gradle:

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

Replace <latest-version> with the current version from Maven Central.

2. Request call permissions

Anchor link to

Request required permissions at runtime using the helper function:

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

Anchor link to

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

Java example

Anchor link to
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

Anchor link to

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

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

4. Configure call settings (optional)

Anchor link to

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

Example usage

Anchor link to
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")
Anchor link to