Giter Club home page Giter Club logo

Comments (9)

frangeris avatar frangeris commented on May 29, 2024 4

Now you can, userInteraction in 2.0.1 #122 (comment)

from react-native-push-notification.

brianjd avatar brianjd commented on May 29, 2024

If I understand the question correctly - aren't you able to inspect the value of 'foreground' in the notification?

from react-native-push-notification.

avishayil avatar avishayil commented on May 29, 2024

Hi,
Yes I am able to log the value. few problems for my usecase:
Usecase: when a notification appears I want to achieve to things:

  1. On receive - check the data of the notification and validate it, then decide if to display it to the user.
  2. On click - perform a custom action based on the notification data (I.E, navigate to a specific article page using navigator).

Problems:

  1. When a notification appears while the app is running, the action is being performed regardless if the user clicked on the notification or haven’t.
  2. When attempting to send a local notification, I can’t figure when the user clicked on the notification or received it. Because the onNotification both listens to receive / click, It would create endless loop and every time I’ll press the notification - new notification would arrive.

    onNotification: function(notification) {
        console.log( 'NOTIFICATION:', notification );
        PushNotification.localNotification({
            /* Android Only Properties */
            // id: 0, // (optional) default: Autogenerated Unique ID
            title: notification.title, // (optional)
            ticker: "My Notification Ticker", // (optional)
            largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
            smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"

            /* iOS and Android properties */
            message: notification.message // (required)
        });
// setTimeout(() => {
// _navigator.to('main.post', notification.message, {
// article: {
// title: notification.message,
// link: JSON.parse(notification.data).url,
// }
// });
// } ,500);
    },

from react-native-push-notification.

pewh avatar pewh commented on May 29, 2024

Hi,

I was able to receive notification and got Object {foreground: false, message: "hello world", collapse_key: "do_not_collapse"}. But when I click notification, I got same value Object {foreground: false, message: "hello world", collapse_key: "do_not_collapse"}.

From the documentation said onNotification is called when a remote or local notification is opened or received. So is there any method to distinguish between received and opened? I want to trigger action when notification opened .

This is what I want:
app run in background -> got notification -> notifcation clicked -> run app into foreground -> change route to certain page

Edited:
I use remote gcm

PushNotification.configure({
      senderID: GCM_SENDER_ID,
      popInitialNotification: true,
      onRegister: async (pushRegistration) => {
          <registering>
      },
      onNotification: (notification) => {
        console.log('notification', notification)
      },
    })

from react-native-push-notification.

ch0992 avatar ch0992 commented on May 29, 2024

i have same problem too. how can i seperate when receive and onClick. Always same AppState & foregroud value. i want when click the notification then move to url of notification messages.

from react-native-push-notification.

xphaul avatar xphaul commented on May 29, 2024

@ch0992 did you managed to solve your problem?

from react-native-push-notification.

IronTony avatar IronTony commented on May 29, 2024

Hi, and sorry for the silly question, but how can I userInteraction to redirect user to a specific page in app (maybe using router flux)? Or also in general, how can I use userInteraction?

from react-native-push-notification.

soundaryad10 avatar soundaryad10 commented on May 29, 2024

how can I userInteraction to redirect user to a specific page in app (maybe using router flux)? Or also in general, how can I use userInteraction?

from react-native-push-notification.

crzycoder avatar crzycoder commented on May 29, 2024

@frangeris can you guide us how to navigate to specific screen by clicking notification in background state..
Thanks

from react-native-push-notification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.