Skip to content

Commit d769d55

Browse files
fix: default options for activation & deactivation
1 parent d7ce4e2 commit d769d55

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/module.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,16 @@ export async function setRingerMode(
112112
* @returns {Promise<void>} - Resolves when the operation has finished. If an error occurs, it will be rejected with an instance of Error. On Android, this function returns undefined.
113113
*/
114114
export async function activateAudioSession(
115-
options: AVAudioSessionActivationOptions = {
116-
runAsync: true,
117-
}
115+
options?: AVAudioSessionActivationOptions
118116
): Promise<void> {
117+
118+
const finalOptions: AVAudioSessionActivationOptions = {
119+
runAsync: true,
120+
...options,
121+
};
122+
119123
if (!isAndroid) {
120-
return VolumeManagerNativeModule.activateAudioSession(options.runAsync);
124+
return VolumeManagerNativeModule.activateAudioSession(finalOptions.runAsync);
121125
}
122126
return undefined;
123127
}
@@ -128,15 +132,19 @@ export async function activateAudioSession(
128132
* @returns {Promise<void>} - Resolves when the operation has finished. If an error occurs, it will be rejected with an instance of Error. On Android, this function returns undefined.
129133
*/
130134
export async function deactivateAudioSession(
131-
options: AVAudioSessionDeactivationOptions = {
135+
options?: AVAudioSessionDeactivationOptions
136+
): Promise<void> {
137+
138+
const finalOptions: AVAudioSessionDeactivationOptions = {
132139
restorePreviousSessionOnDeactivation: true,
133140
runAsync: true,
134-
}
135-
): Promise<void> {
141+
...options,
142+
};
143+
136144
if (!isAndroid) {
137145
return VolumeManagerNativeModule.deactivateAudioSession(
138-
options.restorePreviousSessionOnDeactivation,
139-
options.runAsync
146+
finalOptions.restorePreviousSessionOnDeactivation,
147+
finalOptions.runAsync
140148
);
141149
}
142150
return undefined;

0 commit comments

Comments
 (0)