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
Related
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?
is there any way out / resource which can guide how we can send the push notifications through a javascript to a specific user (through a device id). We have a web app that contains of a login functionality backed by MySQL. We want to send specific alerts to the specific users who are registered. We are open to take any more hidden detail of user if required to complete this task.
We are currently using the JS push notification library to send push notifications but thats currently static not dynamic.
You could run an ajax-call in the background which calls a script with the user-id as an parameter and that returns the messages you want to show to the specific user. Then you can show the message to the user.
I am making a chat app using node.js and noticed that when a user logs out and then logs back in, they can no longer see any of the previously sent messages.
What is the best way to go about allowing users to see all past messages (or maybe up to a certain number)?
To see previous messages they have to be stored in database, you can use MongoDB to store the messages and display them.One other unconventional way would be to store messages in text file and display them.
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.
I implemented friendly chat. But that is group chat. I am new to firebase. Need docs for creating one to one web chat. How to get list of user accounts and selecting single user to send message? Please help me
If the users communicating have user IDs uid_1 and uid_2.
The database structure should be:
contacts
--uid1
--uid2
--uid3
-- so on (1)
--uid2
--uid1
--uid4
-- so on (2)
messages
--uid1
--uid2
-- Push messages here.(3)
--uid2
--uid3
-- Push messages here also.(4)
Adding Contacts
If USER 1 knows USER 2 you can add USER 2 in location (1) and add USER 1 in location (2). Since you are implementing with user IDs the USERS will be able to send messages if they know the other USER's uid. You can send Chat Invites to exchange uids.
Adding Messages
If USER 1 or USER 2 sends a message add at locations (3) and (4). This implementation will make sure that even if USER 1 deletes a conversation with USER 2, USER 2 will still have a copy and thus ensuring privacy.
These are the key elements to make a basic one-on-one Firebase Chat App.
NOTE: User IDs are provided by Firebase on successful authentication.
Maybe try breaking your problem into individual milestones and learn how Firebase works as you need help in each milestone.
According to what you have written, you have to:
Authenticate Users (https://firebase.google.com/docs/auth/)
Save those user profiles onto the Real-Time Firebase Database in the following data structure (https://firebase.google.com/docs/database/)
List those users in a List / RecycleView (learnhowtoprogram.com/android/data-persistence/firebase-recycleradapter)
Manage the conversation through listeners in the adapter that reference child nodes which serve as rooms between 2 people.
Think about how to make your structure as efficient as possible such as not saving conversations twice under each user but rather saving a reference to a separate 'conversations' node.
I recently implemented this in my location-based app (Occupapp) if you want a live example. You will have to register, add a service and log in from another device and select that service to chat to the owner.