Creating Private Notifications for Web and Mobile Apps Using Notific.io
In a previous post, we took a look at how to create public notifications with Notific.io. Those are notifications that go out to all your users. There will be cases when you want to send notifications only to a subset of your audience. At such a time, you would want to fall back on creating private notifications. In this post, we show you how to set up private notifications with Notific.io.
Creating Private Notifications Using Notific.io
Let’s first take a look at the parameters you can work with while creating private notifications.
The nature of the notification you’re sending out. Danger, success, info, general, and warning are the different types you can choose between.
The title or heading of the notification.
This is where the main content of the notification goes.
A link included within the notification that opens in a new tab. Useful if you’d like the reader to get more information on a separate webpage.
Templates let you save certain messages and send them out as notifications at a later time.
A string that refers to the name of the template, so you can specify which one you want to send out.
Now that we know what the parameters are, let’s take a look at the code to create a private notification.
curl -X POST "https://api.notific.io/v1/APP_ID/private-notifications" \ -H "Accept: application/json" \ -H "Authorization: Bearer API_TOKEN_HERE" \ -d "type"="3" \ -d "title"="Your premium trial ends in a week!" \ -d "body"="Visit the dashboard to renew your premium subscription and have access to our full range of features :)" \ -d "url"="" \ -d "template"="0" \ -d "name"="" \
As you can see, this private notification is meant only for users trialing the premium version of a software. This particular message doesn’t come from a template, so those fields remain empty.
The same private notification can be created using our PHP SDK. You can learn more about the PHP SDK in this post. Here’s how you would recreate the aforementioned private notification in PHP.
$notific->createPrivateNotification([ 'type' => '3' 'title' => 'Your premium trial ends in a week!' 'body' => 'Visit the dashboard to renew your premium subscription and have access to our full range of features :)' ]);
There are a few different channels through which private notifications can be delivered to users. The default channel is the web application, which means users will see messages directly on your website. This is how Notific.io relays notifications straight out of the box after installation.
In addition to that, there are a few more delivery channels that can be tapped. Notific.io supports email notifications so you can reach users’ inbox. There are also real-time notifications that are delivered using a couple of different kinds of technology. The first is WebSocket, a protocol that enables low-overhead communication between clients and servers. Web Push allows you to communicate with users in real time even when they’re not on your app or website. You can choose between these different channels and combine them in different ways to communicate with users effectively.