Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ are not listed here.

### Fixed

- **iOS:** `setup()` applies its options to CallKit right away. When the app had run before, CallKit kept the options of the previous launch (the module builds the CallKit provider from the stored settings when it loads), and calling `setup()` again didn't change them either. An app that sets up from native code can now call `[RNCallKeep setup:]` again to change them; `setup()` from JavaScript is still ignored then, as documented. ([#732](https://github.com/react-native-webrtc/react-native-callkeep/pull/732), @c960657)
- **Android:** The foreground service keeps the importance and sound of the notification channel named by `foregroundService.channelId` when that channel already exists; its name still follows `channelName`. An app could pass its own channel, such as the one its incoming calls ring in: creating it again with `IMPORTANCE_NONE` lowered its importance (from high to low on a Galaxy S24, Android 16), and its notifications stopped alerting.
- **Android:** A call created in a process where the CallKeep module doesn't exist gets its foreground service. The service read the stored settings only through the module: a call placed from the Phone app while the app isn't running started no foreground service, and an incoming call added from native code, whose connection loads the settings, crashed the app with a `NullPointerException`. Without the module, the notification opens no activity.
- **Android:** `checkIsInManagedCall()`, `setAudioRoute()` and `toggleAudioRouteSpeaker()` no longer crash the app on Android 7 with `NoSuchMethodError`: they called Android 8 APIs. Before Android 8, `checkIsInManagedCall()` reports any ongoing call (there are no self-managed calls then), `setAudioRoute()` rejects and `toggleAudioRouteSpeaker()` does nothing.
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import RNCallKeep from 'react-native-callkeep';

Stores the settings without the rest of `setup()`, which already calls it. It takes the same options as [`setup()`](setup.md#options) and keeps the `ios` or `android` part for the current platform.

On iOS, CallKit's configuration (`appName`, `imageName`, `ringtoneSound`, `supportsVideo`...) is read once, when `setup()` creates the CallKit provider: a later `setSettings()` doesn't change it.
On iOS, `setSettings()` doesn't change CallKit's configuration (`imageName`, `ringtoneSound`, `supportsVideo`...): call [`setup()`](setup.md) again for that.

```js
RNCallKeep.setSettings(options);
Expand Down
4 changes: 3 additions & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ RNCallKeep.setup(options).then(accepted => {});

`setup` calls internally `registerPhoneAccount`, `registerEvents` and `setSettings`.

You can call `setup()` again to change the options, for example when the user changes a preference. On iOS the new CallKit options (`includesCallsInRecents`, `supportsVideo`, `ringtoneSound`...) apply to the next calls. If you [set up from native code](#setup-from-native-code-ios), call `[RNCallKeep setup:]` again instead.

You can alternatively just call `setSettings()` with the same option as `setup()` to define only your settings.

## Setup from native code (iOS)

On iOS you can also perform setup in `AppDelegate`. Doing this allows capturing events prior to the react native event bridge being up. Please be aware that calling setup in `AppDelegate.m` will ignore any subsequent calls to `RNCallKeep.setup();`.
On iOS you can also perform setup in `AppDelegate`. Doing this allows capturing events prior to the react native event bridge being up. Please be aware that calling setup in `AppDelegate.m` will ignore any subsequent calls to `RNCallKeep.setup();` from JavaScript: to change the options, call `[RNCallKeep setup:]` again.

```objective-c
@implementation AppDelegate
Expand Down
19 changes: 17 additions & 2 deletions ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ + (void)initCallKitProvider {
}
}

// Applies the stored settings to the CallKit provider. The provider may exist already: created when the
// module loaded, from the settings stored during the previous launch, or by an earlier setup().
+ (void)configureCallKitProvider {
if (sharedProvider == nil) {
[self initCallKitProvider];
} else {
sharedProvider.configuration = [RNCallKeep getProviderConfiguration:[self getSettings]];
}
}

+ (NSString *) getAudioOutput {
@try{
NSArray<AVAudioSessionPortDescription *>* outputs = [AVAudioSession sharedInstance].currentRoute.outputs;
Expand All @@ -204,7 +214,7 @@ + (NSString *) getAudioOutput {

+ (void)setup:(NSDictionary *)options {
RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil];
[callKeep setup:options];
[callKeep setupWithOptions:options];
isSetupNatively = YES;
}

Expand All @@ -218,6 +228,11 @@ + (void)setup:(NSDictionary *)options {
return;
}

[self setupWithOptions:options];
}

- (void)setupWithOptions:(NSDictionary *)options
{
#ifdef DEBUG
NSLog(@"[RNCallKeep][setup] options = %@", options);
#endif
Expand All @@ -226,7 +241,7 @@ + (void)setup:(NSDictionary *)options {

[self setSettings: options];

[RNCallKeep initCallKitProvider];
[RNCallKeep configureCallKitProvider];

self.callKeepProvider = sharedProvider;
[self.callKeepProvider setDelegate:self queue:nil];
Expand Down
Loading