【问题标题】:Unable to dismiss notification from notification bar in react native push notification (Android)无法在反应本机推送通知(Android)中从通知栏中关闭通知
【发布时间】:2020-05-17 15:29:15
【问题描述】:

我正在创建一个无法从通知区域关闭通知的剩余应用程序,我尝试了很多方法来解决这个问题,但仍然没有任何帮助, PushNotification.clearLocalNotification(parseInt(notification.id, 10)); 尝试这样做以关闭通知(不删除/取消)。还尝试了类似的解决方案,如PushNotification.cancelLocalNotifications({ id: `${parseInt(notification.id, 10)}` });。但仍然没有任何帮助。我尝试记录节点包,我可以在清除通知 java 函数/取消函数中看到记录,仍然没有从通知区域中解散

编辑:我想关闭操作(按钮)按下时的通知。

【问题讨论】:

    标签: android react-native push-notification react-native-android react-native-push-notification


    【解决方案1】:

    使用autoCancel: true 在点击通知时关闭通知

    export const LocalNotification = () => {
      PushNotification.localNotification({
        autoCancel: true,
        bigText:
          'This is local notification demo in React Native app. Only shown, when expanded.',
        subText: 'Local Notification Demo',
        title: 'Local Notification Title',
        message: 'Expand me to see more',
        vibrate: true,
        vibration: 300,
        playSound: true,
        soundName: 'default',
        actions: '["Yes", "No"]'
      })
    }
    

    【讨论】:

    • 对不起,我之前没有提到,我需要关闭操作按钮按下时的通知
    • 我用过自动取消:点击后仍然通知没有消失.. @HariharanSivakumar
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多