簡體   English   中英

如何在 React Native 中創建 Firebase 推送通知組?

[英]How to create Firebase push notifications group in React Native?

我在使用 Firebase 在 React Native 中創建推送通知組時遇到問題,當我收到許多推送通知時,我想將其創建為 1 個組,如 WhatsApp(如下圖中的紅色圓圈)。

在此處輸入圖像描述

我試圖尋找許多示例,但沒有找到解決方案。 請任何人幫助我創造這樣的東西。

謝謝。

使用本機推送通知

// 創建通道

import PushNotification, {Importance} from 'react-native-push-notification';
...
  PushNotification.createChannel(
    {
      channelId: "channel-id", // (required)
      channelName: "My channel", // (required)
      channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
      playSound: false, // (optional) default: true
      soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
      importance: Importance.HIGH, // (optional) default: Importance.HIGH. Int value of the Android notification importance
      vibrate: true, // (optional) default: true. Creates the default vibration pattern if true.
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
  );

// 這會顯示每個新通知一段時間,然后將其推送到組中

PushNotification.localNotification({
      channelId: 'channel-id',
      title: `New message`,
      message: 'Hello world',
}) 

// 這組消息

PushNotification.localNotification({
      channelId: 'channel-id',
      id: 'messages',
      group: 'messages',
      groupSummary: true
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM