1
我想向本地推送通知添加声音。 我正在使用RN 0.45.1和 react-native-push-notifications 3.0.0反应本机推送通知声音
我设法使用默认声音在iOS和Android中安排通知。 我没有设法添加自定义声音。
我有MP3类型的声音文件。 我试过如下:
- 发生在我的项目文件夹中的文件: '/src/assests/sounds/sound.mps'(文件夹我的项目里)
比:
import notificationSound from '../src/assests/sounds/sound.mps';
PushNotification.localNotificationSchedule({
message: 'Test message',
date: new Date(Date.now() + (60 * 1000)),
repeatType: 'time',
repeatTime: 60 * 1000,
sound: notificationSound,
});
- 另一个尝试是: 把声音文件机器人文件夹下:.. \机器人\应用\ SRC \主\ RES \原料\ sound.mp3
和通知是:
PushNotification.localNotificationSchedule({
message: 'Test message',
date: new Date(Date.now() + (60 * 1000)),
repeatType: 'time',
repeatTime: 60 * 1000,
sound: sound.mp3,
});
嗨,我读了故宫的文档。如果你看看我的第二个选项,我尝试了什么文档说,但没有运气 –
我认为你使用'声音'作为参数,但你需要使用'soundName' 所以 '''sound:sound.mp3 ,'''是不适当的 '''soundName:sound.mp3,'''是合适的 –
谢谢Nisarg, 我在你的第一个回复中错过了'soundName'属性...我正在关注文件位置 –