Personalized web push notifications - web

I want to send web push notifications to registered users, are there any best practices on how to implement the cases when multiple users have access to the same device and one should not see the message of another user.
Thanks in advance.

A web push notification subscription is tied to the browser, not the device.
What you need to do is, map this id with your registered user when he logs in from a particular browser. Also, you need to remove the subscription id mapping with any other users in the system.
In the case of multiple users using the same browser, the above logic will make sure that at a time, a particular browser subscription id is linked only to a single user.
And when you want to send a notification to a registered user, you can retrieve all push subscription IDs linked to this user in your database, and trigger notifications to those subscription IDs.
And don't forget to unmap a subscription id when the user logs out from a browser. Otherwise, he will continue to receive all notifications even if he has logged out.

Related

Web push notifications update VAPID keys

I previously used different push notification provider (they did not use VAPID keys) and got users subscribed to the service. Now, when I switched the push notification provider I'm in a situation where I kinda lost all previous subscribers, because they will not get the permission window again as they have already agreed to receive notifications. Is there a way to automatically update(re-subscribe?) the subscriber as he visits my webpage with a VAPID key pair so the "old" subscribers can still receive my push notifications?
Me again, I found that if you get the subscription with getSubscription() and then use the unsubscribe() function followed by another subscribe() function, you "update" the subscription and everything works without user interaction. The only real "issue" is that you can only update the subscription if the same user visits your page again.

How to make your own push notification service for your website

I am working on a website, where I want to make a feature of notifications, when a user visits my website, they are asked for notifications permission and when they allow it, they will get notifications from my website, and whatever product I want them to get notified by.
Like for example when I visit some websites, they ask me for notifications permissions and when I allow the, I get notified through notifications then. That's all I want for now.
How can I achieve this functionality, I have follow this tutorial, but still confused how the users who allowed the notifications get detected and how all of them are notified then ?
Web Push library for node.js is just a sender.
You should obtain a subscription JSON object from the browser using Notification API and Service Worker API and then send it to your server, where put it in the database of your choise.
When you will need broadcast notifications, you can retrieve subscription and use a web-push library (for php is also available :)
Note that is a right flow looks following as:
1) Retrieve subscription from the browser
2) Send and store it on your web-server
3) Create notification prototype (just object)
4) Broadcast notification prototype ID you have created to the users
5) Service Worker receive one and fetch notification prototype from your server by ID
6) Show notification using browser API in service worker
For more see here links
https://developers.google.com/web/fundamentals/codelabs/push-notifications/
https://developers.google.com/web/ilt/pwa/introduction-to-push-notifications/

Dedicated Services Account and Embedded Sending Experience

We are using the EnvelopeView: CreateSender endpoint on the server side and are authenticated under a service account we have dedicated for this process. Ultimately, we send a URL such as https://demo.docusign.net/Member/StartInSession.aspx?StartConsole=1&t=<GUID>&DocuEnvelope=<ENVELOPEID>&send=1 back to the end user to pick the signers, and populate tags.
All works fantastically, however, we were hoping to make it so the user can only see and populate the information for this single document. Currently, once the user clicks the link they are essentially authenticated as our backend service account and if they open another tab in their browser and go to (https://demo.docusign.net) they can see all documents and even change the password of the account if they wanted.
Is there a way to restrict this in any way? Would the experience be different if purchased an “API” account not tried to use an actual user account on the backend? Yes, we know about OAuth, but we don’t really want to impersonate the sender and prefer to keep a dedicated service account.
An "API" account would give you the same issues as dedicating one of your current users as a "Services Account," so I don't think that's a solution.
Instead, I suggest that you move all of the functionality that's needed upstream into your app. That way you will not need to present the Sender view to your users.
Your app can enable your users to:
choose who the envelope will be sent to
choose/edit the email messages, etc
choose the documents that will be sent
etc
If you have preset templates that include the document tabs/fields for the signers then there is no reason for the sender to deal with the sending screen for picking the tab/field locations on the documents.
This type of app will also give a smoother user experience to your users since they'll stay in your app rather than bouncing over to DocuSign for part of the task.

OneSignal website push flow

I'm implementing OneSignal website push notification for my website. For now I just want to enable push notifications for the registered users. I had expected that there would be some callback methods after the users clicks "Allow" or "Block", but there aren't any. I see that I have to work with OneSignal.isPushNotificationsEnabled() and OneSignal.push(["getIdsAvailablegetIdsAvailable",..]), but I'm not sure how everything is supposed to come together.
What I think I should do is every time a registered users is at the homepage to execute something like this:
if isPushNotificationsEnabled
OneSignal.push(["getIdsAvailablegetIdsAvailable",..])`
send_user_id_to_server_where_it_is_saved_in_the_database
else
OneSignal.push(["registerForPushNotifications"..])
end
One thing that bothers me is that if this code gets executed and the user clicks "Allow" it will not trigger any code and a notification will never get to my server that the user has actually allowed push notifications. I'll have to wait for the user to come back or refresh the page. Is this how it's supposed to work or am I missing something?
After chatting with the OneSignal support, they made available a new method
OneSignal.on('subscriptionChange', function (isSubscribed) {..}]);
which will fire when the subscription status of the user changes. Note that a complete and valid subscription is based on a couple of things: notification permission, whether there is a background worker active to fetch notifications, whether the web database to store the user ID and registration token information is intact, whether the user has manually opted out or not.
There is a separate method that is not in the documentation, that is just for checking the user permissions:
OneSignal.push(["getNotificationPermission", function(permissions) {..}]);
The permissions parameter can be "default", "granted" and "denied".

Azure Notification Hub and sending pushes to individual users?

I recently migrated an old push notification app to a new Azure Mobile Service. The MPNS API, apparently, has changed. It also automatically created a notification hub. Now instead of being able to define a clear channel URI for the message to be sent to, I need to specify a tag. I find it very hard to find information on this and how to send messages to individual users from Azure Mobile Services.
How is this done now?
Its actually pretty simple. Use your unique user identifier as a tag when you register.
Here is an example.
Registration reg = new AppleRegistration(token)
reg.getTags().add(userId)
hub.createRegistration(reg)
Now when you want to send to that user, send via the tag.
hub.sendNotification(Notification.createAppleNotification(payload), userId)
With Notification Hubs you have a few different options. Tags are the way of identifying who you want to push to (i.e. when you push to tag X, any device that has registered with tag X will be pushed to). So if you want to push based off of channel URI, when you register from the device, you should use the Channel URI as one of the tags. If you want to be able to push to all of a single user's devices, you'd need a different mechanism of knowing who the user is (i.e. registering with the username as a tag and then pushing to the username).

Resources