Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在react native push notifications中远程设置自定义声音_Android_React Native_React Native Firebase_Remote Notifications_React Native Push Notification - Fatal编程技术网

Android 如何在react native push notifications中远程设置自定义声音

Android 如何在react native push notifications中远程设置自定义声音,android,react-native,react-native-firebase,remote-notifications,react-native-push-notification,Android,React Native,React Native Firebase,Remote Notifications,React Native Push Notification,我已经配置了远程通知,一切正常。现在我想为我的远程通知设置一个自定义声音。我试过很多方法,但都不管用。 我正在使用反应本机推送通知和反应本机firebase 我在android/app/src/main/res/raw/sound.mp3中放置了一个自定义声音文件 我还尝试了soundName:“sound.mp3” 我感谢在这方面的任何帮助。谢谢。:) 下面是示例代码: PushNotification.configure({ onRegister: async function(

我已经配置了远程通知,一切正常。现在我想为我的远程通知设置一个自定义声音。我试过很多方法,但都不管用。 我正在使用反应本机推送通知反应本机firebase

我在
android/app/src/main/res/raw/sound.mp3
中放置了一个自定义声音文件

我还尝试了
soundName:“sound.mp3”
我感谢在这方面的任何帮助。谢谢。:) 下面是示例代码:

PushNotification.configure({
      onRegister: async function(token) {

      },
      onNotification: function(notification) {
        console.log(notification);
      },
      senderID: 'xxxx',
      permissions: {
        alert: true,
        badge: true,
        sound: true,
      },
      playSound: true,
      soundName: 'sound.mp3',
      popInitialNotification: true,
      requestPermissions: true,
    });
  }````

对于android,您必须提供带有频道id的频道id:“您的频道id”,如果该频道不存在,则可能不会触发通知

注意:如果没有频道,通知可能无法工作

  PushNotification.createChannel(
    {
      channelId: "channel-id", // (required)
      channelName: "My channel", // (required)
      soundName: "sound.mp3",
      importance: 4,
      vibrate: true,
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
  );

在soundName选项中,您输入此频道的自定义声音名称(对于默认声音,请使用“default”),并在发送通知时使用频道Id。对于android,您必须提供带有频道Id的频道Id:“您的频道Id”,如果频道不存在,则可能不会触发通知

注意:如果没有频道,通知可能无法工作

  PushNotification.createChannel(
    {
      channelId: "channel-id", // (required)
      channelName: "My channel", // (required)
      soundName: "sound.mp3",
      importance: 4,
      vibrate: true,
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
  );

在soundName选项中,为该频道输入自定义声音名称(对于默认声音,使用“默认”),并在发送通知时使用频道Id

请共享您的code@Rajan服务器端还是客户端?客户端代码。请查看:)请共享您的code@Rajan服务器端还是客户端?客户端代码。请查看:)