addNotificationReceivedListener 在使用 expo-notifications 时未收到 expo react native 中的通知

问题描述

我在项目中使用 expo react native,我在项目中使用 expo-notifications 包。

我在 app.json 文件添加了 "useNextNotificationsApi": true 在expo对象下的android对象下所以expo.android.useNextNotificationsApi:true。

我还在从我的服务器发送到 expo 服务器的消息上设置了 ExperienceId,我正在使用 https://github.com/expo/expo-server-sdk-node 包进行发送。

   messages.push({
               to: red_user.fcm_token,sound: 'default',title: "Stylist Response",body: "Stylist has agreed to fulfill the request",data: {
                   experienceId: "@glamcentralng/GlamCentral",order: order._id,stylist_response: "agreed" 
               },})  

在我的 expo react 本机应用程序中,我使用了前面提到的 expo-notifications 包,并且在我的类组件中进行了以下设置。

import * as Notifications from 'expo-notifications';

.
.
.
.

 componentDidMount() {

    //Not working at all 
    Notifications.addNotificationReceivedListener( notification => {
      console.log(notification);
      this._handleNotification(notification)
    });

    //Working well
    Notifications.addNotificationResponseReceivedListener(response => {
      console.log(response);
    });
  
    this.registerForPushNotificationsAsyncNew();
}

addNotificationReceivedListener 在它进来时没有收到通知,但我认为它是我真正的 Android 设备上的正常通知(我没有使用模拟器)。根据文档,当我单击通知时, addNotificationResponseReceivedListener 应该处理它并且确实如此。所以 addNotificationReceivedListener 不起作用,但 addNotificationResponseReceivedListener 运行良好。

还要补充的一点是,我在按照文档进行注册函数中获得了一个令牌。

不知道如何解决这个问题,因为我已经检查了此处和 github 上的其他线程。任何帮助表示赞赏。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...