PWA notifications without backend - javascript

I am making a todo app with Javascript (PWA). There will be reminders for the todos. I want to send notifications to the user to remind them. Tasks and remind time will be stored in localStorage.
So now I want to send notifications without any backend. I have tried some tutorials, they all require a backend or Google push services for it.
Is there any way to send notifications without them?
I think the serviceWorker will have to keep running in the background and get the current time. Remind the user if current time and remind time matches.
So how to do it?

Related

How to send browser notifications for specific users?

I want to add browser notifications for my rails app.
I'm having trouble adding notifications to specific users.
For example, i have user and lesson models.
And I want to send notifications to the user about the beginning of the lesson.
But how do I send notifications, not to all users, but only to those related to the lesson?
The first thing you should do is to get and store the subscription object for each user. Then, in your application, you should send a notification only for related users.
There are a bunch of different gems for it, e.g. https://github.com/zaru/webpush

PWA + Native APP Push Notifications (Firebase)

I'm looking for ways to handle push notifications from PWA and Native apps.
We have both, and now when we send a push, I want that if user has installed both native and pwa on their mobile, to only receive the push from native, so we would avoid spamming the user with dublicate notifications. We are using Firebase for push notifications.
What are the best practices to handle this dublicate notification issue? I couldn't find any related info on the web.
This can only be achieved if the user is logged in. In this case you can store the user-identity together with the push notification token. Then on the server you can check which user has registered two notification tokens and send your message only to one token.
If your app does not provide any user identity, I see no way to achieve it.
But, are you sure this is the desired behavior?
Keep in mind that the user can have more than two tokens, for example if he uses your pwa on multiple devices/browsers.

Pubnub: Background Processes for an Auction App Development

Hello I am developing an auction app like tophatter.com. I want to implement an application that has background process in it. I want this process to run forever until I stop it
http://eoction.com thatss our current site. The problem on our site when we refresh the page the auction also restart. We need something like a continuous process like tophatter.com if you refresh the page it will load the updated auction process.
I found this great service called pubnub. I am thinking we need a background process for this? This will process the auction on the pubnub blocks and then when we visit the site we will just need to query on its updated process?
Does pubnub support something like this?
PubNub Web Page Best Practices
When user refreshes your web app page or navigates to another page there are things you need to consider as a web app developer no matter what technologies you may be using. I will address, at a high level, the things you need to do when PubNub is integrated into your web page.
Restore Parameter
Whether the user interrupts your connection to PubNub or it is a network failure, you will want PubNub to reconnect and continue where it left off as much as possible. The PubNub JavaScript SDK has a initialization parameter called restore that when set to true, will reconnect to PubNub and get missed messages after the connection is dropped and reestablished.
var pubnub = new PubNub({
subscribeKey: "mySubscribeKey",
publishKey: "myPublishKey",
ssl: true,
uuid: getUUID();
restore: true
});
Reuse UUID
It is important to reuse the same UUID for each end user as this will allow PubNub to identify that user uniquely when it comes to Presence so that it doesn't produce new join events for the same end user. The PubNub JavaScript SDK actually generates a UUID and stores it in localStrorage and reuses it by default but very likely you have your own UUID that you would like to use for each of your end users.
Last Message Received Timetoken
If the network disruption is brief as is the case with a page refresh or page navigation, then missed messages are retrieved when restore:true is implemented in the init as stated above. But when the user is offline for more than say 5 minutes, you may want to retrieve missed messages on one or more channels. The best way to do this is to keep track of the timetoken of the last received message by storing it in localStorage every time a message is received via subscribe callback. When the user comes back online and it is has been more than 5 minutes since they were last online, call history using this last received message timetoken on each channel that you need to get missed message from.
Subscribe to Channels
Finally, you'll want to make sure that the user is subscribed to the channel they expect to be based on what their state prior to the connection disruption. If it is a page refresh, you likely just want to resubscribe them to the same list of channels. To do this, you just need to keep a list of channels they are currently subscribed to, once again, in localStorage. If the user navigates to a new page and this causes a full page reload (modern web apps should not require this, but...) then you may want to unsubscribe from some channel(s) and subscribe to new channel(s), it just depends on what that page navigation means to your app. Modern web app frameworks do not require full page reload for page navigation since the web app acts more like a desktop app than older web apps. And again, if the the user was offline for quite some time (more than 5 minutes) then it may not make sense to subscribe them to the same channels that they were subscribed to before. Really depends on your use case.
And by the way, Tophatter uses PubNub ;) but all of the above are generic best practice guidelines and recommendations and is not referencing any one app in particular.
EDIT: To address you question specifically, as pointed out in comments below...
You can't implement long-running process in PubNub BLOCKS (not currently, anyways), so you will need a server process for this. When the user refreshes the page, you just need to hit your server for current state. If using PubNub to keep this progress bar updated in realtime, you just subscribe to that channel that is sending the state of that progress bar and update your client. Using the same best practices I provided above are still necessary.

Notification on client desktop without involving server

I am building web application to keep track of activities of users using an Angular front-end and the back-end using PHP. User click start button, what activity he/she is doing. When user click the start button, timer start to run. But sometimes user may forget to stop timer or just close the browser. What i want to is to notify to the user desktop with some notification something like web push notification when activity goes too long. And my question is
1.Is it possible to notify the user when he/she close my web in browser,but his/her desktop is on? and how?
2.How to send push notification to the user desktop without interacting with server?
I see some tutorial like push notification where server send notification but I have nothing update in database I have my clock running in AngularJS. So I have to check clock time also in Angular. As Angular is a framework of JavaScript, I am comfortable with JavaScript too. Any ideas how to use GCM or ServiceWorker or push notification. I am new to GCM, push notification and service worker.
Any suggestions?

How to get access_token via Javascript SDK on SoundCloud?

I'm using the Javascript SDK to access the SoundCloud API and I can't figure out how to maintain the connection using the javascript API.. every time I refresh, it makes you re-connect again, which is crummy for UX.
How can get the access_token so that I can store, and then subsequently, how do I re-send that token to authorize so the user doesn't need to reconnect each time they visit the page.
There's a ton of docs about how to do it with PHP, etc...but nothing in Javascript SDK about access tokens.
I am pretty sure that the SC.isConnected() function was working, but now it just loads the connect button each time.
Everything is working correctly, I just don't want the user to have to reconnect each time.
You can use SC.accessToken() to access it. We are planning to provide some sort of session persistence and a better backend integration in the next 2 months.

Categories