Notification send in php

Admin
2 minute read
0

एक साथ एप्प में नोटिफिकेशन Notification सेंड करना बहुत ही मुश्किल काम है और कई लोग नहीं कर पाते है लेकिन ये पोस्ट देखने के बाद आप आसानी से कर पाएंगे

कैसे कैसे एक से अधिक नोटिफिकेशन Notification सेंड कर सकते है 


१. एक है अलग अलग डिवाइस id पे सेंड कर।
२. एक ही टॉपिक्स के जरिये सभी यूजर को सेंड कर.

दोनों में से २ नो वाला सही वे है नोटिफिकेशन  Notification  सेंड करने का और इसके माध्यम से आप आसानी से नोटिफिक्शन Notification  सेंड कर सकते है 


Sending notifications in the app at the same time is a very difficult task and many people are not able to do it but after seeing this post you will be able to do it easily. how to send more than one notification 

 1. One is by sending on different device id. 

 2. By sending to all the users through the same topics.  

The right way to send the notification with 2 nos out of the two is and through this you can easily send the notification.

 

 

<?php

    $title = " Notification title write here... ";
    $message = "Notification description write here... ";
    $topics = "/topics/Write topic name here....";
    $API_ACCESS_KEY = ' Enter API ACCESS KEY here... ';
    
    $fields = array
    (
        'to'  => $topics,
        'priority' => 'high',
        'notification' => array(
            'body' => $message,
            'title' => $title,
            'sound' => 'default',
            'icon' => '',
            'image'=> ' '
        ),
        'data' => array(
            'message' => $message,
            'title' => $title,
            'sound' => 'default',
            'icon' => '',
            'image'=> ''
        )
    
    
    );
    
    
    
    $headers = array
    (
        'Authorization: key=' . $API_ACCESS_KEY,
        'Content-Type: application/json'
    );
    $ch = curl_init();
    curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
    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 );
    echo $result;


?>

Tags

Post a Comment

0 Comments
Post a Comment (0)
Our website uses cookies to fast experience.
Accept !