【发布时间】:2021-11-19 13:32:02
【问题描述】:
我正在使用 react-native-push-notification npm 包。在创建通知通道时,我正在设置自定义声音的路径,如下所示:
PushNotification.createChannel(
{
channelId: 1, // (required)
channelName: 'My Channel', // (required)
channelDescription: 'A channel to categorise your notifications', // (optional) default: undefined.
soundName: 'tone1',
playSound: true,
importance: 4,
vibrate: true,
},
(created) => console.log(`createChannel returned '${created}'`),
);
对于ios,我将声音添加到XCode中的项目根文件夹如下:
但这不起作用,仍然播放默认声音。在 Android 上,自定义声音正常工作。我什至导入了声音文件并手动播放以确保它正常工作:
import SoundPlayer from 'react-native-sound-player';
SoundPlayer.playSoundFile('tone1', 'mp3');
我什至在 soundName 变量中使用了扩展名 .mp3,但它仍然不起作用。
库版本:7.3.2
【问题讨论】:
标签: ios react-native push-notification react-native-push-notification