Closed dozsolti closed 3 years ago
Hi @dozsolti, problems only with notification wich is send from dashboard ? What about api create event ? (TestPush method in your code) And please check this log in Android studio "onMessageReceived" https://github.com/zo0r/react-native-push-notification/blob/1f462d8c669c7eaaa9f0f803b651b768d3855f03/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java#L123
Is the same
@banshiAnton I've get the notification from Android Studtio: V/RNPushNotification: onMessageReceived: Bundle[{data=Bundle[{message=test 24}]}]
is application in foreground ? please check log in your onNotification method
no, the app is closed and as I already said the onNotification is triggered
ok, you can create local notification in this method (onNotification) or try to set meta-data com.dieam.reactnativepushnotification.notification_foreground to true in AndroidManifest.xml (and rebuild)
I've tried to set it to true but is the same result
you can create local notification using data from arguments onNotification
I have nothing against to receive a notification which is not shown and then showing it manually, if that will be the way. But that will be a workaround. A workaround of something that should work and can work because putting my credentials into the example app it works
ok, please check this log in android studio "sendNotification" https://github.com/zo0r/react-native-push-notification/blob/036b194af7340fea01be1bd2de49dffb15fb6140/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java#L176
maybe error occurs when react-native-push-notification lib builds notification
@banshiAnton ok, so if I send a notification (with my TestPush function) it went to onNotification but not to "sendNotification"
getting these in logs:
if no "sendNotification" log probably both values (config.getNotificationForeground() and !isForeground) are quals false https://github.com/zo0r/react-native-push- notification/blob/master/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java#L179 please can you check it
show or not show notification it depend on react-native-push-notification lib logic, connectycube just send push message with data type, push message wich is sent from firebase console has notification type and it independ of react-native-push-notification lib logic
!isForeground will be false when I send it from TestPush because I have to have the app open to press the button that it sends it :))
If I send a notification from the dashboard the "sendNotification" is called:
finally!
i think some problems with in this method https://github.com/zo0r/react-native-push-notification/blob/1f462d8c669c7eaaa9f0f803b651b768d3855f03/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java#L201
can you add log here and check it https://github.com/zo0r/react-native-push-notification/blob/1f462d8c669c7eaaa9f0f803b651b768d3855f03/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java#L591
I think I found something, I'm getting:
D/RNPushNotification: Ignore this message if you sent data-only notification. Cannot send to notification centre because there is no 'message' field in: Bundle[{userInteraction=false, id=2047034221, data=Bundle[{message=Test 27}], foreground=false}]
I've sent no data, only:
i think you can create local notification in onNotification method or rewrite lib logic or use lib version like 3.1.9 (if it possible)
I won't rewrite the library's logic I would choose to not downgrade from 7.2.1 to 3.1.9 if it's not necessary
so I will try to create local notification, but for this I would have to call the PushNotification.configure function twice, (on in index.js for background and one in my PushNotification service to subscribe to ConnectyCube) It will be bad idea?
I found something strange:
If I send a notification from ConnectyCube(dashboard) I've get the message in the data property.
But if I make from local or firebase it doesn't goes to data
No wonder why the library says it doesn't contains a message
Yes, but this is our logic and we can't change it Probably you can create local notification without call PushNotification.configure or create one service (wich use react-native-push-notification) and boot it in index.js
I need to call PushNotification.configure to have access to the onNotification callback.
I've put this into index.js:
and this into my NotificationService.js:
It seems to work so far
No activity for a long time. I think last solution works well
Hi @banshiAnton, I am already using the local notification inside onNotification method but I found a different behavior that this local notification didn't get fire until i send a notification using 'https://fcm.googleapis.com/fcm/send' api. And when i debug my app i found that PushNotification.getChannels returns blank array instead of channel id and when i push notification using 'https://fcm.googleapis.com/fcm/send' api than after i start getting channel id which i need to use in local notification.
Hi,
I've added notifications into my app and by following:
Everything looks to work fine, no crashes no error logs. Unfortunately when I send a notification from the dashboard it doesn't appear on my emulator, but if I send one from firebase it works fine. Local notifications also works as expected. It triggers the onNotification function from index.js but doesn't appear (neither in status bar nor as a little top-popup)
I think it will be an issue in my configurations because I've had to combine 3 or 4 documentations.
android/app/build.gradle![image](https://user-images.githubusercontent.com/17215747/108322942-ba6f7380-71ce-11eb-9487-e63aeed7ede8.png)
android/build.gradle![image](https://user-images.githubusercontent.com/17215747/108322998-cfe49d80-71ce-11eb-92f2-0118b2abb1af.png)
AndroidManifest.xml![image](https://user-images.githubusercontent.com/17215747/108323146-fc98b500-71ce-11eb-98a7-6abac1c59ae4.png)
I've made a NotificationService which is initialized right after the user login is successfully.
![image](https://user-images.githubusercontent.com/17215747/108324347-74b3aa80-71d0-11eb-8c8f-30a8c558cdee.png)
Also I've tried to:
Extra infos:
I've setted the correct server key in the dashboard (first it was only for development, but now I've put the same into production too, nothing changed)
Followed to docs only for Android, nothing iOS related
In my console, after I close my app and send a notification, it seams that it restarts the app![image](https://user-images.githubusercontent.com/17215747/108326047-767e6d80-71d2-11eb-8f98-a853712c4c4b.png)
I send notification (from dashboard) by choosing the Android channel, the testing ENVIRONMENT and "test 13" in the message
In Dashboard/Push Notifications/Queue, status of everything is 'sent'