makis_best Well-Known Member Licensed User Longtime User Mar 4, 2020 #1 Hi. I want through a VB.NET application I created to send notification messages to all users they use my Android application using Firebase services. My code working fine and notification messages take place but only when Android application running in the background or the application is closed. If the application is running then the notifications come writing only Null on body and tittle. What I am missing here? Is there something else I need to look after? The Json I use is like that. B4X: Dim data = New With { .[to] = deviceId, .notification = New With { .body = MaterialComment, .title = "Αλλαγές τιμών.", .sound = "Enabled", .click_action = "Main" } }
Hi. I want through a VB.NET application I created to send notification messages to all users they use my Android application using Firebase services. My code working fine and notification messages take place but only when Android application running in the background or the application is closed. If the application is running then the notifications come writing only Null on body and tittle. What I am missing here? Is there something else I need to look after? The Json I use is like that. B4X: Dim data = New With { .[to] = deviceId, .notification = New With { .body = MaterialComment, .title = "Αλλαγές τιμών.", .sound = "Enabled", .click_action = "Main" } }
Peter Simpson Expert Licensed User Longtime User Mar 4, 2020 #2 @makis_best not unless you have a good reason not to do so, If I were you I would be using firebase push notifications. I developed a solution for one of my clients a couple of years ago which works 100% perfect 100% of the time. You might find it a lot easier to use a B4J application to push notifications to either Android or iOS devices. FirebaseNotifications - Push messages / Firebase Cloud Messaging (FCM) Updated tutorial: https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/ Clarification: The nice thing about FCM is that your app doesn't need to run in order to receive messages. The FirebaseMessaging receiver will be started by the OS when a new message... www.b4x.com Upvote 0
@makis_best not unless you have a good reason not to do so, If I were you I would be using firebase push notifications. I developed a solution for one of my clients a couple of years ago which works 100% perfect 100% of the time. You might find it a lot easier to use a B4J application to push notifications to either Android or iOS devices. FirebaseNotifications - Push messages / Firebase Cloud Messaging (FCM) Updated tutorial: https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/ Clarification: The nice thing about FCM is that your app doesn't need to run in order to receive messages. The FirebaseMessaging receiver will be started by the OS when a new message... www.b4x.com
makis_best Well-Known Member Licensed User Longtime User Mar 4, 2020 #3 @Peter Simpson thank you for your reply. The exact example I use from Android part. I just can't use B4J example cuz the VB.Net application already used for years now and do many many things. One of all that things to do are and notification messages. I don't want to use two separate apps... Upvote 0
@Peter Simpson thank you for your reply. The exact example I use from Android part. I just can't use B4J example cuz the VB.Net application already used for years now and do many many things. One of all that things to do are and notification messages. I don't want to use two separate apps...
Jorge M A Well-Known Member Licensed User Longtime User Mar 4, 2020 #4 Have you tried to send notification with "priority" : "HIGH" ? Upvote 0
aeric Expert Licensed User Longtime User Mar 5, 2020 #5 How about adding title and body to data? Code: Dim data = New With { .[to] = deviceId, .title = "Αλλαγές τιμών.", .body = MaterialComment, .notification = New With { .title = "Αλλαγές τιμών.", .body = MaterialComment, .sound = "Enabled", .click_action = "Main" } } You can also check my VB.NET code Last edited: Mar 7, 2020 Upvote 0
How about adding title and body to data? Code: Dim data = New With { .[to] = deviceId, .title = "Αλλαγές τιμών.", .body = MaterialComment, .notification = New With { .title = "Αλλαγές τιμών.", .body = MaterialComment, .sound = "Enabled", .click_action = "Main" } } You can also check my VB.NET code
makis_best Well-Known Member Licensed User Longtime User Mar 5, 2020 #6 Jorge M A said: Have you tried to send notification with "priority" : "HIGH" ? Click to expand... Yes... I try already... Nothing change. Upvote 0
Jorge M A said: Have you tried to send notification with "priority" : "HIGH" ? Click to expand... Yes... I try already... Nothing change.
Erel B4X founder Staff member Licensed User Longtime User Mar 5, 2020 #7 First step is to use the B4J code to send the messages. Once you see that it works you should compare the JSON string that the B4J code creates to the one that your VB .Net program creates. Upvote 0
First step is to use the B4J code to send the messages. Once you see that it works you should compare the JSON string that the B4J code creates to the one that your VB .Net program creates.
makis_best Well-Known Member Licensed User Longtime User Mar 5, 2020 #8 @aeric I check your code and we don't have differences. Actually your code work both ways? Upvote 0
makis_best Well-Known Member Licensed User Longtime User Mar 5, 2020 #9 @Erel I use B4J code and work fine. I did exactly what you said. I copy the JSON from there. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 5, 2020 #10 All that I can say is that your VB .Net code is wrong. If the json was correct then it would have worked. You know the correct solution: switch to B4J. Upvote 0
All that I can say is that your VB .Net code is wrong. If the json was correct then it would have worked. You know the correct solution: switch to B4J.
aeric Expert Licensed User Longtime User Mar 5, 2020 #11 makis_best said: @aeric I check your code and we don't have differences. Actually your code work both ways? Click to expand... What do you mean both ways? Do you mean "notification" and "data" ? Let us understand, if we send notification, we only can send title and body (and set sound), the notification sent by Firebase Push Notification does not carry any "payload". That is why it is a better way to send "data" and let B4A app to handle the "message" in fm_MessageArrived() sub and raise an internal notification. Upvote 0
makis_best said: @aeric I check your code and we don't have differences. Actually your code work both ways? Click to expand... What do you mean both ways? Do you mean "notification" and "data" ? Let us understand, if we send notification, we only can send title and body (and set sound), the notification sent by Firebase Push Notification does not carry any "payload". That is why it is a better way to send "data" and let B4A app to handle the "message" in fm_MessageArrived() sub and raise an internal notification.
makis_best Well-Known Member Licensed User Longtime User Mar 5, 2020 #12 @aeric you correct... After I change B4X: .notification = New With { to B4X: .data = New With { everything works as it should be. Thank you all for your help. Upvote 0
@aeric you correct... After I change B4X: .notification = New With { to B4X: .data = New With { everything works as it should be. Thank you all for your help.
Bladimir Silva Toro Active Member Licensed User Longtime User Apr 21, 2020 #13 Hi @makis_best Can you give me an example in VB.NET of how to send the notification by FireBase If you want, can you inform me how can I do it? I only have the example in B4J I appreciate you so much Upvote 0
Hi @makis_best Can you give me an example in VB.NET of how to send the notification by FireBase If you want, can you inform me how can I do it? I only have the example in B4J I appreciate you so much
makis_best Well-Known Member Licensed User Longtime User Apr 21, 2020 #14 Bladimir Silva Toro said: Hi @makis_best Can you give me an example in VB.NET of how to send the notification by FireBase If you want, can you inform me how can I do it? I only have the example in B4J I appreciate you so much Click to expand... Check @aeric solution on post #5 I did exactly the same. If you have problem I am here to help. Upvote 0
Bladimir Silva Toro said: Hi @makis_best Can you give me an example in VB.NET of how to send the notification by FireBase If you want, can you inform me how can I do it? I only have the example in B4J I appreciate you so much Click to expand... Check @aeric solution on post #5 I did exactly the same. If you have problem I am here to help.
Bladimir Silva Toro Active Member Licensed User Longtime User Apr 21, 2020 #15 Thank you very much you are the best @makis_best Upvote 0
ddefrain Member Licensed User Longtime User Sep 24, 2021 #16 makis_best said: @aeric you correct... After I change B4X: .notification = New With { to B4X: .data = New With { everything works as it should be. Thank you all for your help. Click to expand... In a few words firebase tooks the notification word as a command (I think), use a different word Thank you very much Best regards!!! Upvote 0
makis_best said: @aeric you correct... After I change B4X: .notification = New With { to B4X: .data = New With { everything works as it should be. Thank you all for your help. Click to expand... In a few words firebase tooks the notification word as a command (I think), use a different word Thank you very much Best regards!!!
aeric Expert Licensed User Longtime User Sep 25, 2021 #17 You may also want to check my code at GitHub: GitHub - pyhoon/firebase-vbnet: Firebase push notification send to topic (VB.NET) Firebase push notification send to topic (VB.NET). Contribute to pyhoon/firebase-vbnet development by creating an account on GitHub. github.com Upvote 0
You may also want to check my code at GitHub: GitHub - pyhoon/firebase-vbnet: Firebase push notification send to topic (VB.NET) Firebase push notification send to topic (VB.NET). Contribute to pyhoon/firebase-vbnet development by creating an account on GitHub. github.com