Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Deekshith's avatar

How do i open specific page in my android when click the push notification which has been sent by laravel

How do I open specific page in my android app when click the push notification. I have created a php script to push the FCM push notification but its just opening app front page..... I want the push notification to redirect to a differet page which has api => /api/get-notifications

public function send_push_notification($device_id,$title,$content) { //API URL of FCM $url = 'https://fcm.googleapis.com/fcm/send';

  /*api_key available in:
  Firebase Console -> Project Settings -> CLOUD MESSAGING -> Server key*/
  $api_key = "api key goes here"


  // prepare the message
    $message = array(
      'title'     => $title,
      'body'      => $content,
      'vibrate'   => 1,
      'sound'      => 1,
    );

    $registrationIds = array($device_id);


    $fields = array(
         'registration_ids' => $registrationIds,
         'data'             => $message,
         'notification' => array(
         'title' => $title,
         'body' => $content,
         'vibrate'   => 1,
         'sound'      => 1
        )
        );

  //header includes Content type and api key
  $headers = array(
      'Authorization: key='.$api_key,
      'Content-Type:application/json'
  );

  $ch = curl_init();
  curl_setopt( $ch,CURLOPT_URL,$url);
  curl_setopt( $ch,CURLOPT_POST,true);
  curl_setopt( $ch,CURLOPT_HTTPHEADER,$headers);
  curl_setopt( $ch,CURLOPT_RETURNTRANSFER,true);
  curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER,false);
  curl_setopt( $ch,CURLOPT_POSTFIELDS,json_encode($fields));
  $result = curl_exec($ch);
  curl_close($ch);
  return $result;

}
0 likes
2 replies
douglasakula's avatar

I think you might need to do deep linking within the android implementation. I know this guys branch.io have deep linking solutions for this. It might be worth checking out

saber13812002's avatar

i implement deeplink in my app and in laravel i dont know how to send link with laravel-fcm module

is there any method in brozot/laravel-fcm library to send deep link ?

i try

        $notificationBuilder->setBody('Hello world')
                        ->setSound('default')->setClickAction('bazarshahr://customer.app/order') 

but didnt work as well

Please or to participate in this conversation.