Find current active View when reciving a push notification


#1

Hello all,

Im trying to get the current Active view when a push notification is recived,

For Example:
i have a messaging system, and i wanna check if the user is currently on the MessageViewPage then just update the message list else if the user is on any other page show a modal.

push.on('notification', (data) => {
      if(isMessageViewPAge) { update } esle { GoToMEssage}
    });

Basiclly this is the idea. So i want to check every time a push notification is retrieved the current active view.


#2

I would have a Subject exposed in a service, and call next on it every time a push notification comes in. When the MessageViewPage becomes active, subscribe to the Subject and update the list. When other pages become active, subscribe to the Subject and pop a modal. I think that’s more flexible and robust than fooling around trying to figure out what the active view is from inside the notification.


#3

And how would you do that :slight_smile: