【问题标题】:Custom Sound is not getting played after added in configuration also in react-native-push-notification在 react-native-push-notification 中添加配置后,自定义声音也不会播放
【发布时间】:2021-06-15 07:38:48
【问题描述】:

下面是我的代码。我已将 soundName 值添加到声音文件名。我已将声音文件添加到 android 目录中的“原始”文件夹中。但它仍然在播放默认通知声音。

  PushNotification.localNotification({

        /* Android Only Properties */
        channelId: 'default-channel-id',
        autoCancel: true, 
        largeIcon: 'ic_launcher', 
        smallIcon: 'ic_launcher', 
        color: 'red', 
        vibrate: true, 
        vibration: 300, 
        tag: 'some_tag', 
        group: 'group',
        groupSummary: false, 
        ongoing: false,
        actions: null,
        invokeApp: true,
        when: null,
        usesChronometer: false,
        timeoutAfter: null,

        /* iOS only properties */
        category: '',

        /* iOS and Android properties */
        id: this.lastId,
        title: config.title,
        message: config.message,
        userInfo: {screen: 'home'},
        playSound: true,
        soundName: 'sound_one.mp3',
        number: 10,
    });

【问题讨论】:

    标签: react-native react-native-android react-native-push-notification


    【解决方案1】:

    通过使用自定义 soundName 创建通道解决了此问题。 创建通道时,如果您想要自定义声音并在“原始”文件夹中添加声音文件,则必须定义声音名称。 定义自定义声音后,您必须重新安装应用程序。

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      • 1970-01-01
      • 2019-04-07
      相关资源
      最近更新 更多