QuickBlox / quickblox-react-native-samples

quickblox-react-native-samples
BSD 3-Clause "New" or "Revised" License
17 stars 27 forks source link

Push Notification Issue: When clicking on a notification, neither onNotificationOpenedApp nor getInitialNotification is being called. #63

Closed AndyDesign999 closed 7 months ago

AndyDesign999 commented 8 months ago

In the Android platform, messaging().onMessage() is working as expected, but onNotificationOpenedApp and getInitialNotification are not functioning as anticipated. I aim to manage navigation to the chat room screen when the user opens the app by clicking on the notification.

const onNotificationOpenedAppFromBackground = async () => {
    const unsubscribe = messaging().onNotificationOpenedApp(
      async remoteMessage => {
        console.log(
          'App opened from BACKGROUND by tapping notification:',
          JSON.stringify(remoteMessage),
        );
      },
    );
    return unsubscribe;
  };

  const onNotificationOpenedAppFromQuit = async () => {
    const message = await messaging().getInitialNotification();

    if (message) {
      console.log(
        'App opened from QUIT by tapping notification:',
        JSON.stringify(message),
      );
    }
  };
VladimirNybozhinsky commented 7 months ago

@AndyDesign999 Hi! 
This is Vladimir from QuickBlox.

If I understand correctly, you use Firebase to send and receive push notifications. We have not yet implemented this functionality in our samples. Perhaps this article will help you.

Best regards, Vladimir

AndyDesign999 commented 7 months ago

@VladimirNybozhinsky I want to achieve navigation to a particular screen when clicking on a QuickBlox chat notification. I don't find any code in the sample. How can I achieve it?

VladimirNybozhinsky commented 7 months ago

Hi @AndyDesign999! In RN Chat Sample, the following packages are used to receive push notifications:

import PushNotification, {Importance} from 'react-native-push-notification';
import PushNotificationIOS from '@react-native-community/push-notification-ios'; 

RN Chat Sample has not yet implemented the functionality of opening a specific screen by clicking on a push notification. But you can implement this yourself using the example shown in the documentation "@react-native-community/push-notification-ios"

You can also not use the libraries from the sample and use other resources for this, for example Firebase, the code from which you provided in the question.

You can also ask this question in our discord in the React Native channel https://discord.gg/RvkCR3kT

Best regards, Vladimir

AndyDesign999 commented 7 months ago

@VladimirNybozhinsky Thanks!