Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Notification drawer doesn't close after click on action that navigates you to app #1914

Closed
andrew-stupchuk opened this issue Mar 18, 2021 · 13 comments

Comments

@andrew-stupchuk
Copy link

Bug

I have a notification with actions that navigates me to different pages of my app. After i click any of action notification removes from notification drawer but doesn't close it. Click on notification(not actions) doesn't have this problem, all works as expected.

Library version: 7.2.2
react: 16.13.1
react-native: 0.63.3

Steps To Reproduce

  1. Open notification drawer
  2. Click notification action that navigates you to any page of your app
    ...

Describe what you expected to happen:

  1. Notification drawer is closed
  2. User navigated to app page
@andrew-stupchuk andrew-stupchuk changed the title Notification drawer doesnt close after click on action that navigates you to app Notification drawer doesn't close after click on action that navigates you to app Mar 18, 2021
@Dallas62
Copy link
Collaborator

Hi @andrew-stupchuk
No information and not able to reproduce with exemple project.
Regards,

@andrew-stupchuk
Copy link
Author

@Dallas62 What information you need? You can clarify the problem before closing it

@Dallas62
Copy link
Collaborator

Such as configuration, how you trigger, how you (try to) receive the action, or at least a reproduction exemple.

@andrew-stupchuk
Copy link
Author

andrew-stupchuk commented Mar 18, 2021

@Dallas62

  1. send local notification with
PushNotification.localNotification({
  channelId: 'myChannel',
  title: 'Title',
  message: "Notification message",
  actions: ['Messages', 'News']
})
  1. Click 'Messages' action on notification
  2. my onNotification function
onNotification(notification) {
   if (notification.userInteraction) {
       return this.processNotification(notification);
    }
    
    this.sendLocalNotification(notification);
}

In my app i received everything as expected: in my onNotification function i received notification.userInteraction === 'Messages'. The problem is after i click 'Messages' action notification drawer doesn't close.

react-native info:

System:
    OS: macOS 11.2.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 641.58 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 10.23.0 - ~/.nvm/versions/node/v10.23.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v10.23.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 23, 26, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.1, 29.0.2
      System Images: android-23 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_212 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.13.1 => 4.14.0 
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.3 => 0.63.3 

@Dallas62
Copy link
Collaborator

https://github.com/zo0r/react-native-push-notification#notification-actions

userInteraction is a boolean, notification.action is the value pressed (in your exemple: one of this values ['Messages', 'News'])

So notification.userInteraction === 'Messages' can't work

@andrew-stupchuk
Copy link
Author

@Dallas62 sorry, i want to say, that receive notification.action === 'Messages'.

@andrew-stupchuk
Copy link
Author

andrew-stupchuk commented Mar 18, 2021

the notification is removed from notification drawer correctly, but notification drawer doesn't closed. That is my problem. I want to close it after click notification action

@Dallas62
Copy link
Collaborator

Does the call to PushNotification.localNotification contains only:

  • title
  • message
  • actions
  • channelId
    ?

Is there ongoing set ?

@andrew-stupchuk
Copy link
Author

no, i don't set it

@Dallas62
Copy link
Collaborator

You should be able to do this:

PushNotification.removeDeliveredNotifications([ notification.id ])

@andrew-stupchuk
Copy link
Author

this will remove my notification from notification drawer, right? but there is autoCancel prop in PushNotification .localNotification that do this for me.

@Dallas62 Dallas62 reopened this Mar 18, 2021
@Dallas62 Dallas62 pinned this issue Mar 18, 2021
@Dallas62
Copy link
Collaborator

I just publish the version 7.2.3,
This should resolve your issue

@andrew-stupchuk
Copy link
Author

now everything works as expected, thanks @Dallas62

@Dallas62 Dallas62 unpinned this issue Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants