繁体   English   中英

反应本机Firebase推送通知不触发生产FCM /云功能

[英]React Native Firebase Push Notifications not firing production FCM/ Cloud Functions

我正在尝试实现推送通知,并为开发人员和产品部署相同的云功能。 对于开发人员,我每次都能收到通知:

在此处输入图片说明

但是对于prod我收到一个错误,它将永远不会发送:

在此处输入图片说明

这是我的通知方法:

// shows the users of the chat channel
const messageId = functions.database.ref(
  "/ChatMessages/{channelType}/{channelId}/{messageId}"
);

// HANDLE NEW NOTIFICATION
    export const notificationCreatedEvent = messageId.onCreate((snapshot: any, event: any) => {
      // channelType is for if it is a public or private chat- if it is public it will list the mountain
      const { channelId } = event.params;

      const messageData = snapshot.val();
      const message = messageData.text;

      const trimmedMessage = truncate(message, 20, true);

      // notification channel
      const notificationRef = admin
        .database()
        .ref(`/Notifications/${channelId}`);

      const notificationBody = (message.slice(0, 12) === "https://fire") ? "new image message" : trimmedMessage
      const payloadPrivateUser = {
        notification: {
          title: "Private Message",
          body: "Message: "+notificationBody
        }
      }
      const payload = {
        notification: {
          title: "Message in channel "+ channelId,
          body: "Message: " + notificationBody
        }
      }

      notificationRef
        .once("value")
        .then(async userListSnapshot => {
          const userList = await (<any>Object).values(userListSnapshot.val());
          const response = channelId.length > 50 ? await admin.messaging().sendToDevice(userList, payloadPrivateUser): await admin.messaging().sendToDevice(userList, payload);
        }).catch(err=> {
          console.log(err)
        })
    });

不知道为什么由于两者都有相同的promise错误,为什么会在一个与另一个中触发?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM