Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open deep link url when click on Fcm notification

I'm using Google's Fcm to send notification to my Android client

I want to open specific screen with Deep Link url eg. example://my.app/products

Here is endpoint to send notification using REST api

https://fcm.googleapis.com/fcm/send
Content-Type: application/json
Authorization: key={SERVER_KEY}

{
 "to" : "{Firebase client token}",
 "collapse_key" : "type_a",
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification"
     "click_action": "example://my.app/products"
 }
}

This request sends notification to my specified client, but does not open Deep Link, when clicking on push nothing happens

Is there a way to open Deep Link from Fcm Push ?

like image 605
Mahdi Javaheri Avatar asked Aug 01 '20 08:08

Mahdi Javaheri


People also ask

Can you deep link push notifications?

Deep linking allows push notifications to send users directly to specific pages within an app, making it easy for users to reconsider an abandoned cart, view new content, shop a sale, or fall in love with new features.

How do I send a link in FCM notification?

If you want to send the notification manually from FCM panel then: then make a key like: link and put the value i.e. your fb link. Then send the notification to that particular user or a topic or a segment from FCM panel. You can handle it inside your application like: Extract the data from notification then...

Does FCM use Websockets?

1 Answer. Show activity on this post. FCM (Firebase Cloud Messaging) uses HTTP and XMPP Server Protocol serving JSON and Plain Text both.

What is Senderid in FCM?

The Sender ID is used in the client side application to register to FCM from the device. Copy the Server Key. You must provide the Server Key in the Engagement server while configuring an application to send push messages.


1 Answers

This feature is not mentioned in Fcm documentation but i tried some sort of tests on my own and figured out the solution:

Instead of click_action we need to put link:

https://fcm.googleapis.com/fcm/send
Content-Type: application/json
Authorization: key={SERVER_KEY}

{
 "to" : "{Firebase client token}",
 "collapse_key" : "type_a",
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification"
     "link": "example://my.app/products"  <<-- Here is the solution
 }
}
like image 107
Mahdi Javaheri Avatar answered Sep 22 '22 06:09

Mahdi Javaheri