iOS Question Set Category push notification from php file

Israel Gallegos

Member
Licensed User
Hi I am trying to add notifications with actions to my project

I have followed the tutorial step by step to add the categories, create actions and sub userNotification_Actions

The problem is: How I should Set the category in the push notification message from a php file?


Can anybody help me?

**php file content**
<?php
include('../con/Config.php');
if ($_GET['u'] != '') {
$UUID = $_GET['u'];
$title = $_GET['t'];
$body = $_GET['b'];


if (strpos($UUID, "IOS_") !== false) {
$serverKey = 'XXXXXXXXXXXXXXXXXXXXXX';
$UUID = str_replace("IOS_","",$UUID);
// NOTIFICATION WITH ACTION
$notification = array('title' =>$title , 'body' => $body, 'sound' => 'default');
}


$arrayToSend = array('to' => $UUID, 'notification' => $notification, 'data' => $notification, 'priority'=>'high');

$json = json_encode($arrayToSend);
$url = "https://fcm.googleapis.com/fcm/send";

$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: key='. $serverKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
$response = curl_exec($ch);
if ($response === FALSE) {
die('0 ' . curl_error($ch));
}
curl_close($ch);
}

mysqli_close($con);

?>
 

aeric

Expert
Licensed User
Longtime User
Upvote 0
Top