Android Question I would add the push notification to my app

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
Ok, I trying the example to first post but I have the error compiling in this part of code:
B4X:
Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then ReturnAnd
End Sub

the error is :

Error description: Undeclared variable 'returnand' is used before it was assigned any value.
Error occurred on line: 46 (Main)
If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then ReturnAnd
I included FirebaseNotifications and Core Library.
 
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
Then, I compiled the App but not receive the msg.
I did all these steps:
  1. created a new project in firebase
  2. used the same name of Android Packet in the App Project
  3. Add the manifest snippets to the manifest editor
  4. put the json file in the b4a folder
  5. sent the msg from firebase console
what I forgot?
 
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
Found the problem, I've forgot a part in the manifest.
Now I receiving the push msg with "Null" text and "Null" label when the app is showed but with correct message when the app is in background. Why?
 
Last edited:
Upvote 0

KMatle

Expert
Licensed User
Longtime User
1. If you see an example here, please use it strictly "as it is" first to prevent unnecessary mistakes like typos
2. Please send the messages from B4J (as the example provides)
3. Why via B4J? So you can manage what you send and you can see/check what the Google api returns (like "successful", "fail" and a reason)
4. Learn what a map is (take a search)
5. As you will see, the line

B4X:
 n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)

is trying to get "title" and "body". I assume that what you send via console does not contain a map with these keys. So it's NULL.

6. If you get errors or you have questions, please post your code AND logs together. You could have posted the output of these line (from the example)

B4X:
Log($"Message data: ${Message.GetData}"$)

It contains the map of the message which was sent. If you take a look at it, you will not find "title" and "body". The next logical step is to change the map which was sent or the code of the receiver.
 
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
Hi,
I don't know B4J and I never used it. However, I downloded and installed it. I compiled the FCMPush project and made the .jar file. Then I downloaded the B4J Package project and compiled it. Then when I tryed to buid the FCMPush.jar I receive the "Error parsing manifest file".
What can be the error?
 
Upvote 0

Walter Scafati

Active Member
Licensed User
Longtime User
Yes, without to compile it works. Thanks Erel!
But is possible make the app for to send the push notifications or must I realize a PHP page for to perform this?
 
Upvote 0
Top