I want to send Push Notifications from Azure using PHP to a single user. I'm already doing it to "All Users" registered in my cloud but I cant find the code (in PHP) that allow me to Push IT to one in espesific.
This is the (simple) code that I use to send to multiple Users, I guess it could be something similar:
include "NotificationHub.php";
$connection = "Endpoint=sb:......";
$hub = new NotificationHub($connection, "appetito24hub");
$notification = new Notification("apple", '{"aps":{"alert":{"title":"Estado de la orden", "body":"Tu orden ha cambiado del estado Aceptada a Procesada"}, "id":"4500", "type":"promo"}}');
$hub->sendNotification($notification);
Any Idea? Thx!
In the end, and after checking the absurdly incomplete documentation of Microsoft Azure Notifications, I realize (after reading this article) that you can add the "ServiceBusNotification-Tags" to the header so the notification can be sent to THAT espesific ID.
The real change was in the NotificationHup.php (if you downloaded the Sample Code Provided by Azure Team) from this:
$headers = [
'Authorization: '.$token,
'Content-Type: '.$contentType,
'ServiceBusNotification-Format: '.$notification->format
];
to
$headers = [
'Authorization: '.$token,
'Content-Type: '.$contentType,
'ServiceBusNotification-Tags: '.$userTag,
'ServiceBusNotification-Format: '.$notification->format
];
After that, everything worked just perfect.