Skip to content

Commit

Permalink
Update docs on Intent filters and incoming/outgoing call requirements (
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandar-apostolov authored Feb 21, 2024
1 parent edd8490 commit 496521a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 8 deletions.
52 changes: 52 additions & 0 deletions docusaurus/docs/Android/01-basics/03-quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,58 @@ The call type controls the permissions and which features are enabled.
The second argument is the call id and is optional. It's convenient to specify an ID if the call is associated with an object in your database.
As an example if you're building a ride sharing app like Uber, you could use the ride id as the call id to easily align with your internal systems.

#### Incoming / outgoing calls
If you intend to support incoming and outgoing calls the SDK must know which activities to call in the notification `PendingIntent`.
In order to be able to accept and send incoming calls via the default notification handler provided by the SDK, you need to handle the intent actions in your manifest.

The SDK defines the following actions:
```kotlin
ACTION_NOTIFICATION = "io.getstream.video.android.action.NOTIFICATION"
ACTION_LIVE_CALL = "io.getstream.video.android.action.LIVE_CALL"
ACTION_INCOMING_CALL = "io.getstream.video.android.action.INCOMING_CALL"
ACTION_OUTGOING_CALL = "io.getstream.video.android.action.OUTGOING_CALL"
ACTION_ACCEPT_CALL = "io.getstream.video.android.action.ACCEPT_CALL"
ACTION_REJECT_CALL = "io.getstream.video.android.action.REJECT_CALL"
ACTION_LEAVE_CALL = "io.getstream.video.android.action.LEAVE_CALL"
ACTION_ONGOING_CALL = "io.getstream.video.android.action.ONGOING_CALL"
```

If you do not support incoming and outgoing calls, you can skip the `<intent-filter>` declarations.

In order to be able to fully utilize the incoming / outgoing feature the SDK needs to know which activity these actions resolve to in order to construct the `PendingIntent`s.
You have to provide this information into your manifest.

The `ACTION_REJECT_CALL` and `ACTION_LEAVE_CALL` are handled by default by the SDK and you do not have to do anything about them.
The `ACTION_ONGOING_CALL` does not mandate an `<intent-filter>` with the consequence that omitting this will result in reduced functionality where the user will not be returned to your app if the notification is clicked.

All the other actions must be declared in your manifest, otherwise the internal `CallService` will fail to create the required notification for a foreground service and thus not start, resulting in an exception.

```xml
<manifest>
<application>
<activity
android:name=".Activity"
android:exported="false"
android:showOnLockScreen="true"
android:showWhenLocked="true"
>
<intent-filter android:priority="1">
<action android:name="io.getstream.video.android.action.INCOMING_CALL" />
<action android:name="io.getstream.video.android.action.ONGOING_CALL" />
<action android:name="io.getstream.video.android.action.ACCEPT_CALL" />
<action android:name="io.getstream.video.android.action.OUTGOING_CALL" />
<action android:name="io.getstream.video.android.action.NOTIFICATION" />
</intent-filter>
</activity>
</application>
<manifest>
```
:::info
You can handle multiple `IntentFilter` within a single `activity` if you prefer or have separate activity for each action.
:::
For more details on notification customization see our [Push Notification Guide](../06-advanced/02-push-notifications/01-overview.mdx).
### Rendering video
The call's state is available in [`call.state`](../03-guides/03-call-and-participant-state.mdx) and you'll often work with `call.state.participants`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,44 @@ You only need to create the `Activity`/`Activities` will be called when the Push
The different actions we provide are:

* `io.getstream.video.android.action.INCOMING_CALL`: Action used to process an incoming call. The `activity` that handles this action should show options to accept/reject the call. You can use our [RigningCallContent](../../04-ui-components/04-call/04-ringing-call.mdx) component to build your screen. This screen can be shown when the device is locked, by adding some arguments on the manifest.
* `io.getstream.video.android.action.OUTGOING_CALL`: Action used to process an outgoing call. The `activity` that handles this action should show options to cancel the call. You can use our [RigningCallContent](../../04-ui-components/04-call/04-ringing-call.mdx) component to build your screen.
* `io.getstream.video.android.action.ACCEPT_CALL`: Action used to accept an incoming call. The `activity` that handles this action should accept the call and show the call screen. You can use our [CallContent](../../04-ui-components/04-call/03-call-content.mdx) component to build your screen.
* `io.getstream.video.android.action.LIVE_CALL`: Action used to go into a live call. The `activity` that handles this action should show the live call screen. You can use our [CallContent](../../04-ui-components/04-call/03-call-content.mdx) component to build your screen.
* `io.getstream.video.android.action.ONGOING_CALL`: Action used to get back into already running call. The `activity` that handles this action should show the call screen. You can use our [CallContent](../../04-ui-components/04-call/03-call-content.mdx) component to build your screen.
These actions need to be included on the `AndroidManifest` while you declare your activities:
``` xml {4,9-11,15,18-20,24,27-29,33,36-38}
``` xml {4,8-10,13,17-19,23,26-28,31,33-35,39,42-44}
<manifest>
<application>
<activity
android:name=".IncomingCallActivity"
android:exported="false"
android:showOnLockScreen="true"
android:showWhenLocked="true"
>
android:showWhenLocked="true">
<intent-filter android:priority="1">
<action android:name="io.getstream.video.android.action.INCOMING_CALL" />
</intent-filter>
</activity>
<activity
android:name=".OutgoingCallActivity"
android:exported="false"
android:showOnLockScreen="true"
android:showWhenLocked="true">
<intent-filter android:priority="1">
<action android:name="io.getstream.video.android.action.OUTGOING_CALL" />
</intent-filter>
</activity>

<activity
android:name=".AcceptCallActivity"
android:exported="false"
>
android:exported="false">
<intent-filter android:priority="1">
<action android:name="io.getstream.video.android.action.ACCEPT_CALL" />
</intent-filter>
</activity>

<activity
android:name=".LiveCallActivity"
android:exported="false"
>
android:exported="false">
<intent-filter android:priority="1">
<action android:name="io.getstream.video.android.action.LIVE_CALL" />
</intent-filter>
Expand Down Expand Up @@ -142,7 +149,7 @@ class MyNotificationHandler(private val context: Context) : NotificationHandler
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
}

// Called when a Ringing Call arrives.
// Called when a Ringing Call arrives. (outgoing or incoming)
override fun onRingingCall(callId: StreamCallId, callDisplayName: String) {
val notification = NotificationCompat.Builder(context, notificationChannelId)
... // Configure your own notification
Expand Down

0 comments on commit 496521a

Please sign in to comment.