B4A Library FirebaseNotifications - Push messages / Firebase Cloud Messaging (FCM)

Status
Not open for further replies.

Bel

Member
Licensed User
Hi
In this push we dont need to google play service looklike gcm?
In gcm or c2dm if device rooted so push not send
 

coslad

Well-Known Member
Licensed User
Longtime User
When i load the Firebase Notification library ,it comes out this error :
"Maven artifact not found"
what does it mean ?
 

Attachments

  • errore.jpg
    7.9 KB · Views: 340

VTSinLincoln

Member
Licensed User
Longtime User
How do I get topic subscription to work on device start-up?

I've set the starter service to start at boot and installed the app then rebooted the device. I can see the starter service and the firebasemessaging service running in the device's Application Manager. However, it doesn't appear to have actually subscribed to my topic, as I don't get a notification when I subsequently send a message to the FCM API.

If I uninstall the app and rebuild it so the starter service doesn't start at boot, then install and run it, my topic subscription works as expected (i.e. I can send a message to the FCM API with the topic in the post request that causes a notification on my device).

Any suggestions gratefully accepted

Vaughan
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
"Maven artifact not found"
what does it mean ?
You need to install the two repositories: https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

How do I get topic subscription to work on device start-up?
You don't need to do anything special. Once the app has subscribed to a topic it will remain subscribed until the app is uninstall. No need to start at boot.

Note that you need to run the app in Release mode in order to test it.
 

VTSinLincoln

Member
Licensed User
Longtime User
You don't need to do anything special. Once the app has subscribed to a topic it will remain subscribed until the app is uninstall. No need to start at boot.

Note that you need to run the app in Release mode in order to test it.

Thanks Erel

It works

I just have to be a bit more patient when the device restarts as it can take a few minutes for the notification to arrive.


V
 

ilan

Expert
Licensed User
Longtime User
WOW, this is amazing. it is really working
thank you very much @Erel!!!!

i have integrated Admob + Push Notification and it is working like a charm!! (please make it also for b4i)
 

driesvp

Member
Licensed User
Longtime User
I'm also facing problems with "Maven artifact..."


I added the manifest snippets for Google play, Firebase and notifications.
The repositories are installed.



Also, I created a Firebase Project.

What can be the problem?
 

ilan

Expert
Licensed User
Longtime User

ilan

Expert
Licensed User
Longtime User
so you copied those 3 snippets

'************ Google Play Services Base ************
'************ Firebase Base ************
'************ Firebase Notifications ************

have you created the json file and put it in the folder where the b4a file is located?

do you have any other attributes in you code?
 

shashkiranr

Active Member
Licensed User
Longtime User
Hi All,

Just one question. If i need to send a massage for just one selected device out of 100 devices, how can I do that?

Best,
SK
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
What can be the problem?
Are you sure that the IDE uses the correct Android SDK (Tools - Configure Paths)?

Just one question. If i need to send a massage for just one selected device out of 100 devices, how can I do that?
Either subscribe each device to a unique topic or use your own server with the token ids (see FirebaseMessaging.Token).
 

shashkiranr

Active Member
Licensed User
Longtime User
Hi Erel,

Thank you for the reply. I am saving individual tokens in the db. what is the format to send the messages using tokens.

Best,
SK
 

DonManfred

Expert
Licensed User
Longtime User
based on this i would try something like

B4X:
Private Sub SendMessage(id As String, Title As String, Body As String)
   Dim Job As HttpJob
   Job.Initialize("fcm", Me)
   Dim m As Map = CreateMap("to": $"${id}"$)
   Dim data As Map = CreateMap("title": Title, "body": Body)
   m.Put("data": data)
   Dim jg As JSONGenerator
   jg.Initialize(m)
   Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
   Job.GetRequest.SetContentType("application/json;charset=UTF-8")
   Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
End Sub
 

shashkiranr

Active Member
Licensed User
Longtime User

Thank you DonManfred.
 

aarroyo

Member
Licensed User
Longtime User
I have a problem , after initializing, do not assign me token and returns me the following error:

Error: Cannot run method from watch expression.
 

Attachments

  • Captura.PNG
    7 KB · Views: 453

alimanam3386

Active Member
Licensed User
Longtime User
Hi

As far as I understand this library ( FirebaseNotification ) is just for push a notify to users , but how can I send a message to an user ? ( without app_key , because it is secrect key and we can't use it in the source code ( client side ))

Regards
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…