I am using PushPad Web Push Notification service using PHP
. I can easily push notifications but they are sent to all browsers. Lets say I have a lot of users.
user 1
user 2
user 3
...
Now I want to send notification to just User 1
. I cannot think of the idea how to do it. Can anyone give me a hint or idea of how this can be achievable? I asked my collegue but he says this is not possible in PushPad. I have no other means of getting information regarding this issue. Thanks for help in advance.
Yes, you can target specific users as described in the docs.
When you subscribe a user to push notifications, attach some metadata to its subscription:
pushpad('subscribe', null, uid: 'User1', uidSignature: 'YOUR_SIGNATURE');
uid
): in this example I use 'User1'
, but you can simply call it '1'
uidSignature
can be generated using the PHP library: Pushpad\Pushpad::signature_for($uid);
pushpad('subscribe')
method and the similar pushpad('uid')
method in the Javascript SDK referenceWhen you send push notifications from your server (with the PHP library) you can target specific users:
$notification = new Pushpad\Notification(array(
'body' => "Hello world!"
));
# deliver to a user
$notification->deliver_to('User1');
# deliver to a group of users
$notification->deliver_to(['User1', 'User2', 'User3']);