【发布时间】:2020-12-29 20:54:45
【问题描述】:
我正在使用react-native-push-notifications npm 包将本地通知传递给用户。由于本地通知只会影响一个用户,我必须为所有用户使用远程通知服务。但我已经阅读了指南,其中大多数都告诉我们必须登录 FCM 控制台并从那里发送通知。
但是,在我的应用程序的上下文中,我试图以编程方式从应用程序向所有已安装该应用程序的用户发送通知。是否可以使用react-native-push-notification 发送给所有用户而不直接从 FCM 发送?
本地通知的当前代码
const localNotification = () => {
PushNotification.localNotification({
autoCancel: true,
largeIcon: "ic_launcher",
smallIcon: "ic_notification",
bigText: "Hi, user. You have a new order",
color: "green",
vibrate: true,
vibration: 300,
title: "New Order",
message: "Received a new order",
playSound: true,
soundName: 'default',
actions: '["Accept", "Reject"]',
});
};
此通知仅影响一位用户。由于无法每次都登录 FCM 并发送通知,因此如何向所有用户发送相同的信息。
【问题讨论】:
标签: javascript reactjs react-native firebase-cloud-messaging