创建通知渠道反应原生

BeH*_*ppy 3 android push-notification react-native

我正在使用react-native-firebase v6来处理推送通知。由于此版本中没有创建频道 ID功能,在 React Native 项目中创建频道 ID 的解决方案是什么?

小智 5

你可以使用这个库https://github.com/zo0r/react-native-push-notification 然后

      PushNotification.createChannel(
    {
      channelId: "channel-id", // (required)
      channelName: "My channel", // (required)
      channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
      soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
      importance: 4, // (optional) default: 4. Int value of the Android notification importance
      vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
  );
Run Code Online (Sandbox Code Playgroud)