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

Status
Not open for further replies.

Manolete

Member
Licensed User
Hi DonManfred,

Thanks a lot, I will use it right now!

I appreciate the excellent help and support.
Regards,
Manuel
 

Croïd

Active Member
Licensed User
Longtime User
Please where thread solution #272 ?

works fine with console firebase only !

B4X:
[jobname=fcm, success=true, username=
, password=, errormessage=, target=class b4j.example.main
, taskid=1, req=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest@3c4b1fb8, tag=java.lang.Object@7267e742
, fx=anywheresoftware.b4j.objects.JFX@2fac8a71, httputils2service=null]
{"message_id":8878541930547848266}
 
Last edited:

Croïd

Active Member
Licensed User
Longtime User
Please create a new thread for your question.
Post all relevant infos.
DONT POST ERROR AS IMAGE. Post it as TEXT!
Search the forum for similar problems... I´m sure it is asked in the past.

#272 Don
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I saw the PICTURE!
And i told you to post errors as text. In a newly created thread.

DON´T expect any more answers from me. I´ll put you on my ignore list. I´n not interested in helping here. Even i´m not interestent to spent my time for this.

Good luck.
 

Croïd

Active Member
Licensed User
Longtime User

Sorry Don, I modified to not mislead others !! and I deleted image as requested
 

Croïd

Active Member
Licensed User
Longtime User
A last try to help:
Based on the error the server key seems to be wrong.
Look at the FCM tutorial and watch out how to get the server-key
Use the serverkey to send a notification.

Thanks Don and Sincerely sorry for my mistake
 

Kwame Twum

Active Member
Licensed User
Longtime User
Hello everyone, I'd like to know if the FCM Sender ID is mentioned any where in the Library or it's implementation. An app I'm building currently can't receive messages from my server nor from the FCM notifications console. I've been through all the necessary steps.

I cURLed the FCM server with both the Server Key and a generated Token from the app and got back the response in red:

B4X:
curl --header "Authorization: key=AAAAeArR1Dg:APA91bH4GAkOSEcnLU-XXXXXXWB29u70MUM7wQ" \
     --header Content-Type:"application/json" \
     https://fcm.googleapis.com/fcm/send \
     -d "{\"registration_ids\":[\"cHKKRHRVVWw:APA91XXXXXXXXOaB1kl2t8\"]}"

{"multicast_id":8444809106756048113,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}

I've reported the matter to the FCM support and apparently, the Server key doesn't match the Sender ID. I know the Server Key is correct because I copied it from the FCM Console. The Sender ID however is not mentioned anywhere in my app. So the MismatchSenderId error is quite baffling.

The google-services.json file however contains the correct Sender ID from the FCM console.
FCM support asked me to check my code as I might be generating a token for multiple sender id. A bit confused here. Any help is greatly appreciated. Thank you.

PS. I already have another app working well with FCM, it sends and receives payloads just fine. So I know I've done what needs to be done.


EDIT: SOLVED!
I found this file: googleservices.xml in the res/values folder.

I guess this file is supposed to be deleted and regenerated on every compile. But it somehow stays the same. My guess is: It's been so ever since a previously deleted FCM project I used and this xml file mentions the Sender ID from the deleted project.

The file was marked readonly, after removing the readonly attribute and recompiling, it now references the correct Sender ID. I hope this helps someone else.
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
What is the use of
B4X:
If StartingIntent.IsInitialized AND fm.HandleIntent(StartingIntent) Then Return
?
Why Return ?
 

paul fredrick

Member
Licensed User
Longtime User
i have tested FirebaseNotification and FirebaseAuth... works, but i would like to store the token when user subscribe with google-service or with another metod

Public Sub SubscribeToTopics
fm.SubscribeToTopic("general") 'you can subscribe to more topics
Log(fm.token)
End Sub

when user sign in store ID in authentication tab, but this ID not works to SendMessageToSingleDevice

Sub Auth_SignedIn (User As FirebaseUser)
Log("SignedIn: " & User.DisplayName)
lblName.Text = "Hello: " & User.DisplayName
auth.GetUserTokenId(User,False)
End Sub

Thanks
 

incendio

Well-Known Member
Licensed User
Longtime User
Is there a time limitation for unsent notification to the devices?

For example, targeted devices not have internet connection for a week, will notification still send after devices get active internet connection?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…