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
2 changes: 1 addition & 1 deletion apps/fabric-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3291,7 +3291,7 @@ SPEC CHECKSUMS:
FBLazyVector: 309703e71d3f2f1ed7dc7889d58309c9d77a95a4
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
hermes-engine: f93b5009d8ccd9429fe2a772351980df8a22a413
hermes-engine: 42d6f09ee6ede2feb220e2fb772e8bebb42ca403
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
RCTDeprecation: a41bbdd9af30bf2e5715796b313e44ec43eefff1
RCTRequired: 7be34aabb0b77c3cefe644528df0fa0afad4e4d0
Expand Down
2 changes: 1 addition & 1 deletion packages/audiodocs/docs/inputs/audio-recorder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Additionally to be able to record audio while application is in the background,
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

<!-- Paste this inside <application> tag -->
<service android:stopWithTask="true" android:name="com.swmansion.audioapi.system.MediaNotificationManager$AudioForegroundService" android:foregroundServiceType="microphone" />
<service android:stopWithTask="true" android:name="com.swmansion.audioapi.system.CentralizedForegroundService" android:foregroundServiceType="microphone" />
</manifest>

```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.swmansion.audioapi

import androidx.annotation.RequiresPermission
import com.facebook.jni.HybridData
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.LifecycleEventListener
Expand Down Expand Up @@ -149,6 +150,7 @@ class AudioAPIModule(
}

// Notification system methods
@RequiresPermission(android.Manifest.permission.POST_NOTIFICATIONS)
override fun showNotification(
type: String?,
key: String?,
Expand Down
16 changes: 12 additions & 4 deletions packages/react-native-audio-api/src/plugin/withAudioAPI.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
AndroidConfig,
createRunOncePlugin,
ConfigPlugin,
withInfoPlist,
createRunOncePlugin,
withAndroidManifest,
withGradleProperties,
withInfoPlist,
withPodfile,
} from '@expo/config-plugins';
const pkg = require('react-native-audio-api/package.json');
Expand Down Expand Up @@ -75,7 +75,7 @@ const withForegroundService: ConfigPlugin<Options> = (
const serviceElement = {
$: {
'android:name':
'com.swmansion.audioapi.system.MediaNotificationManager$AudioForegroundService',
'com.swmansion.audioapi.system.CentralizedForegroundService',
'android:stopWithTask': 'true',
'android:foregroundServiceType': SFTypes,
},
Expand All @@ -86,8 +86,16 @@ const withForegroundService: ConfigPlugin<Options> = (
mainApplication.service = [];
}

mainApplication.service.push(serviceElement);
const existingServiceIndex = mainApplication.service.findIndex((service) =>
service.$['android:name'].includes(serviceElement.$['android:name'])
);

if (existingServiceIndex !== -1) {
mainApplication.service[existingServiceIndex] = serviceElement;
return mod;
}

mainApplication.service.push(serviceElement);
return mod;
});
};
Expand Down