Skip to content

Commit 51f8d9a

Browse files
authored
Merge pull request #503 from react-native-webrtc/add_crash_timeout
Add crash timeout
2 parents 1c798d6 + 27d8c2c commit 51f8d9a

File tree

7 files changed

+357
-147
lines changed

7 files changed

+357
-147
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ Alternative on iOS you can perform setup in `AppDelegate.m`. Doing this allows c
121121
If provided, the maximum number of calls in a single group, used for conferencing (Default: 1, no conferencing)
122122
- `supportsVideo`: boolean (optional)
123123
If provided, whether or not the application supports video calling (Default: true)
124+
- `displayCallReachabilityTimeout`: number in ms (optional)
125+
If provided, starts a timeout that checks if the application is reachable and ends the call if not (Default: null)
126+
You'll have to call `setReachable()` as soon as your Javascript application is started.
124127
- `android`: object
125128
- `alertTitle`: string (required)
126129
When asking for _phone account_ permission, we need to provider a title for the `Alert` to ask the user for it
@@ -139,8 +142,13 @@ Alternative on iOS you can perform setup in `AppDelegate.m`. Doing this allows c
139142
multiple popups to the user at different times.
140143
- `selfManaged`: boolean (optional)
141144
When set to true, call keep will configure itself to run as a self managed connection service. This is an advanced topic, and it's best to refer to [Googles Documentation](https://developer.android.com/guide/topics/connectivity/telecom/selfManaged) on the matter.
145+
- `displayCallReachabilityTimeout`: number in ms (optional)
146+
If provided, starts a timeout that checks if the application is reachable and ends the call if not (Default: null)
147+
You'll have to call `setReachable()` as soon as your Javascript application is started.
142148
143-
`setup` calls internally `registerPhoneAccount` and `registerEvents`.
149+
`setup` calls internally `registerPhoneAccount`, `registerEvents` and `setSettings`.
150+
151+
You can alternatively just call `setSettings()` with the same option as `setup()` to define only your settings.
144152
145153
# Constants
146154
@@ -190,7 +198,8 @@ Self Managed calling apps are an advanced topic, and there are many steps involv
190198
191199
| Method | Return Type | iOS | Android |
192200
| ----------------------------------------------------------------- | ------------------- | :--: | :-----: |
193-
| [getInitialEvents()](#getInitialEvents) | `Promise<String[]>` | ✅ | ❌ |
201+
| [getInitialEvents()](#getInitialEvents) | `Promise<String[]>` | ✅ | ✅ |
202+
| [clearInitialEvents()](#clearInitialEvents) | `void>` | ✅ | ✅ |
194203
| [setAvailable()](#setAvailable) | `Promise<void>` | ❌ | ✅ |
195204
| [setForegroundServiceSettings()](#setForegroundServiceSettings) | `Promise<void>` | ❌ | ✅ |
196205
| [canMakeMultipleCalls()](#canMakeMultipleCalls) | `Promise<void>` | ❌ | ✅ |
@@ -224,14 +233,21 @@ Self Managed calling apps are an advanced topic, and there are many steps involv
224233
225234
226235
### getInitialEvents
227-
_This feature is available only on iOS._
228236
229237
If there were some actions performed by user before JS context has been created, this method would return early fired events. This is alternative to "didLoadWithEvents" event.
230238
231239
```js
232240
RNCallKeep.getInitialEvents();
233241
```
234242

243+
### clearInitialEvents
244+
245+
Clear all pending actions returned by `getInitialEvents()`.
246+
247+
```js
248+
RNCallKeep.clearInitialEvents();
249+
```
250+
235251
### setAvailable
236252
_This feature is available only on Android._
237253

android/src/main/java/io/wazo/callkeep/RNCallKeepBackgroundMessagingService.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.facebook.react.bridge.WritableMap;
2626
import com.facebook.react.bridge.Arguments;
2727
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
28+
import com.facebook.react.jstasks.HeadlessJsTaskRetryPolicy;
29+
import com.facebook.react.jstasks.LinearCountingRetryPolicy;
2830

2931
import static io.wazo.callkeep.Constants.EXTRA_CALLER_NAME;
3032
import static io.wazo.callkeep.Constants.EXTRA_CALL_NUMBER;
@@ -38,11 +40,17 @@ public class RNCallKeepBackgroundMessagingService extends HeadlessJsTaskService
3840
HeadlessJsTaskConfig getTaskConfig(Intent intent) {
3941
Bundle extras = intent.getExtras();
4042

43+
HeadlessJsTaskRetryPolicy retryPolicy = new LinearCountingRetryPolicy(
44+
5, // Max number of retry attempts
45+
500 // Delay between each retry attempt
46+
);
47+
4148
return new HeadlessJsTaskConfig(
4249
"RNCallKeepBackgroundMessage",
4350
Arguments.fromBundle(extras),
4451
60000,
45-
false
52+
false,
53+
retryPolicy
4654
);
4755
}
4856
}

0 commit comments

Comments
 (0)