How to test FCM/GCM integration without server side ?
--
Usually when mobile developers start working with server side APIs/calls not all the APIs have implemented, they mock the response and work on it till the back-side will be ready .
When we talk about FCM , sometimes we face integration problems, which is sometimes related to code implementation itself, or to server side configurations, or server side implementation for push notification . At least android developers would like to ensure that everything from their side work properly and there is no problems in code implementation and device registration .
How we can do that ?
Simply via any rest client like:
1-Advanced REST client.
2-Yet Another REST Client.
3-Rest Web Service Client.
4-HTTP Client Pro.
5-Rest console.
6- Restlet Client.
let’s do it with Restlet Client , you can add Restlet Client to google chrome from here
How to configure push notification ?
Let’s follow these quick steps :
1- URL : http://android.googleapis.com/gcm/send .
2- Method: POST .
3- Headers:
- Content-Type : application/json
- Authorization : key=AIzaS………
So what is key = $$$ ?
Authorization :key=AIzaSyDktPqata_iaiusbdiaasd_adsadalxc-fHHmTs
It is api_key in you google-services.json file , you have to replace $$$ with your current_key value .
4- Body : you need to get device registration ID to your Application id at GCM .
If you have a working code , you can generate it , if not , please check this Helper APP to generate it .
“registration_ids”:[YOUR_DEVICE_REGISTRATION_ID]
5- You need to mock your Json Payload to add it as value in data attribute .
“data”: {
“currency”: “EURO”,
“currency_code”: “EUR”,
“value”:1.0738,
“base_currency”: “USD”,
“status”:”loss”
}
Finally the post-body has to be something like that :
{
“registration_ids”:[“dasX5_6b220:APA91bGvTsnkeuYLuBC9KUTORb-X_tizfsgz7NX0DMuI9STxWGAGCHUSYdYHzYUFQzR2Gl4yKXCyxq20jTBDmcIdB_KGWgFrlngxuvDL29VDGf45tbEf0Iz3_ZLTjE8FyZb1kELb97uP”],
“data”: {
“currency”: “EURO”,
“currency_code”: “EUR”,
“value”:1.0738,
“base_currency”: “USD”,
“status”:”loss”
}
}
once you press send, you have to see the response like this .
Once you have message_id , you will receive a push notification for the registered device id .