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

Status
Not open for further replies.

ricardotm1968

Member
Licensed User
Hi Erel,
i'm starting to develop a new app, i use appcompat library (ver 2.0) , when i try to chenge my GCM to FCM, in the compile send me this error ,

Error.png

if i inactivate the library everthig is fine, is not posible to use both library at the same time?

thanks in advance
 

Bel

Active 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
When i load the Firebase Notification library ,it comes out this error :
"Maven artifact not found"
what does it mean ?
 

Attachments

VTSinLincoln

Member
Licensed 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

Administrator
Staff member
Licensed 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
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
WOW, this is amazing. it is really working :D
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
I'm also facing problems with "Maven artifact..."
upload_2016-6-26_22-44-33.png

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

upload_2016-6-26_22-43-21.png

Also, I created a Firebase Project.

What can be the problem?
 

ilan

Expert
Licensed 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
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

Administrator
Staff member
Licensed 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
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
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
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
Thank you DonManfred.
 
Status
Not open for further replies.
Top