Comments (9)
Now you can, userInteraction
in 2.0.1 #122 (comment)
from react-native-push-notification.
If I understand the question correctly - aren't you able to inspect the value of 'foreground' in the notification?
from react-native-push-notification.
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:
- On receive - check the data of the notification and validate it, then decide if to display it to the user.
- On click - perform a custom action based on the notification data (I.E, navigate to a specific article page using navigator).
Problems:
- 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.
- 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.
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.
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.
@ch0992 did you managed to solve your problem?
from react-native-push-notification.
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.
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.
@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)
- Unable to start receiver com.dieam.reactnativepushnotification.modules.RNPushNotificationActions: java.lang.SecurityException: Permission Denial: android.intent.action.CLOSE_SYSTEM_DIALOGS broadcast from com.package.name requires android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS. HOT 2
- Scheduled notification is not coming android
- wrong sound when update version of app
- Foreground onNotification behaviour on iOS HOT 2
- Why are people still using this outdated library? HOT 3
- Indirect notification activity start (trampoline) from com.xxx blocked HOT 1
- How to pass and get data when notification clicked from .onNotification()
- -
- delete
- update build gradle version
- Scheduled Notifications are not displaying..... HOT 1
- Schedule Daily Notification is not working after few days if i did not open the app
- Android - Push notifications not received when app is closed (Killed/Terminated/etc) HOT 5
- Get onNotification triggered when a remote notification is received HOT 1
- Is there a method to persistently display the badge count, even after all notifications have been cleared or dismissed?
- Asking notification permission for Android 13 and above in react native version 0.61 HOT 1
- How can I ask notification permission for Android 13 and above in react native version 0.61 using POST_NOTIFICATIONS? HOT 1
- Default FirebaseApp is not initialized in this process com.client. Make sure to call FirebaseApp.initializeApp(Context) first. HOT 1
- play the notification sound simultaneously on android and bluetooth device
- Hello, I would like to call a function when the use click to a notification I have looked in the other issues to answer this question. And I have seen many responses to this subject. I need to use PushNotification.configure as well as onNotification: function The problem and when I use this function I get the following error: Default FirebaseApp is not initialized in this process I only use local notifications so I don't have to install firebase. Is there a way to call a function when the user clicks on a notification without using firebase? Thank you HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-push-notification.