FIREBASE: How To Send Topic Notification in IOS App

To send Topic Notification in IOS for which we need Firebase Access Key and users should have subscribed to the topic in your app which you will need to do it internally using Firebase SDK in IOS app.

Here is the sample of PHP code through which you can send IOS notification to users Topicwise.

<?php
define( 'API_ACCESS_KEY', 'KEY-VALUE' );
$msg = array
(
'body' => "abc",
'title' => "Hello from Api",
'vibrate' => 1,
'sound' => 1,
);
$body = array (
"to" => "/topics/news",
"notification" => array(
"body" => "hello there",
"sound" => "default"
),
"data" => array(
"body" => "hello there",
"title" => "IBC24",
"key_1" => "Data for key one",
"key_2" => "Data for key two"
)
);
$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( $body ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
?>