首页 > 解决方案 > Firebase 通知中的权限

问题描述

我在与 Firebase 实时数据库关联的 Google Cloud Platform 中创建了这个函数。当数据库中出现某些内容时,该函数会向移动应用程序发送通知。

正如您在下面看到的,我设置了优先级,以便用户注意到通知

var message = {
    token: tokenSnapshot,
    notification: {
        title: "Title",
        body: "Body",
    },
    android: {
        priority: 'high',
        notification: {
            sound: 'default',
            priority: 'high',
            visibility: 'public'
        }
    },
};

不幸的是,它什么也没做。通知来了,但是当他手动检查是否有东西来时,用户会看到

我在应用程序中使用标准方法

messaging().enable.setBackgroundMessageHandler(async remoteMessage => {
    console.log('Message handled in the background!', JSON.stringify(remoteMessage));
  })

有没有办法让通知带有声音、振动并出现在锁定屏幕上?

我还没有使用react-native-push-notification图书馆。这个图书馆能帮上忙吗?

标签: firebasereact-nativepush-notificationfirebase-cloud-messaging

解决方案


如果您使用的是 firebase-cloud 消息传递,我建议在您的应用中使用 firebase。 https://rnfirebase.io/messaging/usage

确保首先遵循初始设置。

请在此处阅读有关此内容的更多信息。https://rnfirebase.io/


推荐阅读