1-eneable возможностей в xcode
- gope apply → signing & signing of & signings & paculties
. /> < /li>
add: < /p>
Push Notifications - Background Modes ➝ Включить удаленные уведомления
2. Настройте APN в Firebase < /h3>
- Загрузите свой клавиш APNS AUTH APNS .p8 < /strong> на консоль Firebase → Настройки проекта → Обмен облачными сообщениями < /li>
< /ul>
3. Установить необходимые библиотеки < /h3>
npm install @notifee/react-native @react-native-firebase/app @react-native-firebase/messaging
cd ios && pod install && cd ..
< /code>
4. Добавьте свой собственный звуковой файл
Создайте звуковой файл в. ios/yourappname/ - Перетащите его в навигатор проекта xcode → Убедитесь «Скопировать при необходимости». Проверяется
5. Отправить уведомление со звуком через fcm < /h3>
{
"to": "",
"notification": {
"title": "New Alert",
"body": "Sound test",
"sound": "custom_sound.wav"
},
"priority": "high"
}
- do не включить Silent: true или content_available: true
import messaging from '@react-native-firebase/messaging';
import notifee, { AndroidImportance } from '@notifee/react-native';
messaging().onMessage(async remoteMessage => {
await notifee.displayNotification({
title: remoteMessage.notification?.title,
body: remoteMessage.notification?.body,
ios: { sound: 'custom_sound.wav' },
android: {
channelId: 'default',
sound: 'default',
importance: AndroidImportance.HIGH,
},
});
});
< /code>
7. Запрос разрешения < /h3>
В app.js < /li>
< /ul>
useEffect(() => {
NotifyPermissions();
}, []);
async function NotifyPermissions() {
await messaging().requestPermission();
}
< /code>
Это отлично подходит для меня; Нет необходимости ни в чем другое. < /p>
"dependencies": {
"@notifee/react-native": "^9.1.8",
"@react-native-firebase/app": "18.6.1",
"@react-native-firebase/messaging": "18.6.1",
"react": "18.2.0",
"react-native": "0.74.3",
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... e-backgrou