【问题标题】:Expo Push Notifications click eventExpo Push Notifications 点击事件
【发布时间】:2019-07-18 14:36:24
【问题描述】:

在文档中没有找到如何处理点击通知 只有一种方法可以订阅通知,仅此而已。

Notifications.addListener(this._handleNotification);

【问题讨论】:

    标签: react-native push-notification expo


    【解决方案1】:

    您必须使用“origin”属性来确定是否收到或选择了通知。

    _handleNotification = (notification) => {
        if(notification.origin === 'received') {
            // after receive push notification code
        }else if(notification.origin === 'selected'){
            // after click code
        }
    }
    

    【讨论】:

      【解决方案2】:

      对于 ExpoSDK39 及更新版本,您可以查看https://docs.expo.io/versions/latest/sdk/notifications/

      简单地说,您可以使用 Notifications.addNotificationResponseReceivedListener 并检查响应中的actionIdentifier 属性。

      // adds a listener called whenever user interacts with a notification
      // "actionIdentifier": "expo.modules.notifications.actions.DEFAULT",  means user clicked the notification
      responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
        console.log("addNotificationResponseReceivedListener", response);
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-08-22
        • 2021-06-04
        • 1970-01-01
        • 2022-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多