@notifee/react-native
+ @expo/config-plugins
+ expo-build-properties
설치 android-manifest.plugin.js
생성 → app.json
에 플러그인 등록 npx expo prebuild --clean
후 재빌드expo: 53.0.11
빌드 타입: Dev Client
npm install @notifee/react-native
npx expo install expo-build-properties
npm install @expo/config-plugins
app.json
){
"plugins": [
[
"expo-build-properties",
{
"android": {
"extraMavenRepos": [
"../../node_modules/@notifee/react-native/android/libs"
]
}
}
]
]
}
android-manifest.plugin.js
const { withAndroidManifest, AndroidConfig } = require("@expo/config-plugins");
module.exports = function withForegroundService(config) {
return withAndroidManifest(config, async (config) => {
const manifest = config.modResults;
// tools 네임스페이스 보장
if (!manifest.manifest.$["xmlns:tools"]) {
manifest.manifest.$["xmlns:tools"] = "http://schemas.android.com/tools";
}
// Foreground Service 등록
const app = AndroidConfig.Manifest.getMainApplicationOrThrow(manifest);
app.service = app.service || [];
app.service.push({
$: {
"android:name": "app.notifee.core.ForegroundService",
"android:foregroundServiceType": "microphone",
"tools:replace": "android:foregroundServiceType"
}
});
return config;
});
};
app.json
{
"expo": {
"plugins": ["./android-manifest.plugin.js"]
}
}
App.tsx
)import notifee from "@notifee/react-native";
notifee.registerForegroundService(() => new Promise(() => {
console.log("Foreground service started");
}));
import * as Audio from "expo-av";
import notifee from "@notifee/react-native";
const startRecording = async () => {
const { granted } = await Audio.requestPermissionsAsync();
if (!granted) return;
await Audio.setAudioModeAsync({
allowsRecordingIOS: true,
playsInSilentModeIOS: true,
staysActiveInBackground: true
});
const { recording } = await Audio.Recording.createAsync(
Audio.RecordingOptionsPresets.HIGH_QUALITY
);
const channelId = await notifee.createChannel({
id: "recording",
name: "Recording"
});
notifee.displayNotification({
title: "백그라운드 녹음 중",
body: "마이크 ON",
android: { channelId, asForegroundService: true }
});
};
npx expo prebuild --clean # 네이티브 파일 재생성
npx expo run:android # Dev Client 빌드 · 설치
adb logcat | grep "Foreground service started"
로그가 계속 찍히면 성공