My app sends notifications (tested on Android)

After so much difficulty I chose to try to do everything with “HTTP Request” and the old method of Firebase Notification (not the latest in Oauth2).
Once the Device Token has been recovered, the tests in 4 buttons.
(for info I was surprised to see that the Device Token changes sometimes ???)


The first button allows with a POST to register the Device Token to a Subject.

The second button allows you to control the subscription to this Subject.

The third button allows you to unsubscribe from the topic

We can reuse the second to see if we are unsubscribed

And if you are registered you can send a notification, which arrives instantly

And finally I don’t understand the idea of needing a backoffice to manage notifications as I have read everywhere?

Can you please make a small tutorial how you made this push notification. Im new and I have already tried to follow appgyver’s documentation but I don’t know what to do at the http request. Were to store the device token in firebase?

Can you please help
Thanks in advance.

URL : https://fcm.googleapis.com/fcm/send
Method : POST
Headers :
- value : key=AAAA…(firebase)
- header : Authorization
Request body : (that’s the secret)
DECODE_JSON(‘{“priority”: “high”, “to”: “/topics/AAA”, “notification”: {“title”: “TITLE”, “body”: “NOTIFICATION_TEXT”}, “data”: {“story_id”: “FACULTATIF” }}’)
Request body type : JSON

Nothing more for me!

There it is in the case of sending to a subject to which it is subscribed before. Otherwise, to simply send to a person, replace “/topics/AAA” with “TOKEN ID”

Important - The notification does not arrive on the mobile which sends it even if it is subscribed to the subject. You need a second mobile to test!

Important 2 - There you will find all the other commands to subscribe to a topic, unsubscribe, control subscriptions… Server Reference  |  Instance ID  |  Google Developers

To be continued :slight_smile:

2 Likes

Hi Luc

Do I need to change the request body. For example what does the title value need to be changed to my collection name in firebase?

In case I want to send a notification when I new blog post is added in the app how would I do it. With token ID or subscribing to it. Is the token ID same as the device token? How do I subscribe to a topic? I need a detail explanation because i’m pretty new at this stuff and there is no decent documentation or youtube video about it.

I followed these steps Push notifications - Google Firebase but when I open my app and click on a list item, I have linked the flow with the repeated items in the list because I don’t know behind which component I should put that notification flow. But anyway when I click on an item I get undifined error.

Thanks in advance. :slightly_smiling_face:

WARNING YOU MUST USE ANDROID FOR THIS PART TO WORK.
FIREBASE FOR APPLE SET UP AT THE END IT’S ONE ENCRYPTION CERTIFICATE STORY AND THAT’S ANOTHER STORY! :sweat_smile:

Hello,
Before tackling notifications, you have to understand what we are talking about and how it works.
You shouldn’t try to integrate this into a fully functional application, but simply manage to send one simple one.

BUT DON’T FORGET THE MANDATORY PREREQUISITE!
The application must be compiled and published on the STORE it is totally unavoidable. In INTERNAL TEST mode in Android or in TESTFLIGHT mode in Apple it is enough, but it is the minimum.

Why?
I will summarize the scheme of a notification, I note that it seems for everyone so logical that it is never done:
For example when you send a notification to a Token ID… In Firebase we use a request with this Token ID… And for the notification to reach its recipient, Google must know about its existence. And this happens through the application store of the smartphone. The Token ID is mainly generated in the application during the installation (it rarely changes afterwards, but I couldn’t define when and why. I know that it changes if you uninstall and reinstall the application).

Then, let’s imagine that Google keeps a directory that tells which application is installed by which Google AppStore account thanks to this token ID.

So if you don’t compile the application and you don’t install it through the store the token ID will never be known by Google and they won’t be able to make the link.

Then for subscriptions to topics or particular groups in the application, it is another story, but the logic remains the same.

IMPORTANT FOLLOW UP:

Now if the application is compiled and installed by the Store… And that in the application the Token ID has been generated and displayed on a blank page for example in the possible selection mode to be able to copy and paste it. Then, launch the application, display this page… The TOken is there!? If yes, copy it and close the application.

Then, go on POSTMAN.CO it is impossible to circumvent to carry out tests. (create an account it’s free)
Create a POST request
Enter this URL : https://fcm.googleapis.com/fcm/send
In Authorization :
Type: APIKey
Key: Authorization
Value : key=AAAAOb8HuMM:APA91bGAKdsKcMCbnDyGuFmF7UHpoLeiFb8nofTkKhF02T0bXWi5UZZMHCvNpBX9DMkeSm-GjHVLO_NOIxtaM5sZMv4E5Bo8Jxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (your Firebase key)
Add to : header

In Body:

{
“priority”: “high”,
“to”: “YOUR TOKEN ID”,

“notification”:
{ “title”: “Does it work?”,
“body”: “We have a BUG!”
}
}

If the application is closed on the mobile… THE NOTIFICATION ARRIVES!

I’ll try to take more time to make complete explanations including Firebase setup and all the commands to test in Postman and then integrate in AppGyver.

Sorry for my English it is translated by DeepL