Notification count in Angular by the help of node js - javascript

i am new in programming. I have a conceptual question.
I have a API /getNotificationCount/{userId} to get count of any type of notification for every user. {userId} is int value. (Backend API buit in Symfony2)
In front end i am using angular, right now i am calling /getNotificationCount/{userId} API every time(by the help of timeout function) in angular controller(ajax call) to get count.
Is there is any way to do when server hits changes(increase or decrease count) then i will get api request to get count. I searched many thing i found by the help of node js i can do this but i am unable to understand how can i start ? Can anyone please give me suggestion on this ?

Sounds like you need WebSockets, have a look here to get started

try to use firebase to send notification.
for server side you should use firebase admin and messaging function .
i use it in my react native front and nodeJs back project

Related

Web push notification - Do I need to own a server?

I have achieved a simple push notification using source code from here: [https://itnext.io/an-introduction-to-web-push-notifications-a701783917ce][1]
But I want to do more advance by sending push notification remotely to another computer using Chrome like Facebook and some others do.
Now I am able to register subscription and get the endpoint link like this:
{
"endpoint": "https://fcm.googleapis.com/fcm/send/cThXDSA40Mo:APA91bE7lTJvxlF52GsX6huXPogc7C-nAcCrX6r9WrMSAwWToz7UDexDnLnAJJdoG-FSbQfquR8bjpd5Oc_CZQYTHU12gF_7_YmdK06CV77uXhSB6M-6LkmdjMazU5MQisXgjyUEICEd",
"keys": {
"p256dh":
"BGaCEBZSsJoqLU_l1hFWpFRwYMH8dHPkfPrPfyO2Sev_ilBYfFwJ7w4W-ppwKmxdhNTcACbi3sf7f0qerSNmQBI",
"auth":"FPssMOQPmLmXWmdSTdbKVw=="
}
}
But I donĀ“t know how to go forward with this. Still wonder if I need to own a server or not ?
It helps if you have a server, so you can see every step of the process and understand what's happening, but if you strictly want to test your app you could use this companion site to send a notification.

error when I try to fetch calendar events through google API, JS React

For some reason; I get error when trying to get my calendar events through google API. I code in JS and use React and have no idea why it does not work.
I have the token stored in sessionStorage and do get personal information about the user like name email and such stuff but I cannot proceed and get the calendar events. Please help!
I'm not sure what exactly you would like to see inside my App but let me know and I'll provide with the stuff because I do not want to upload the whole project lol
https://gyazo.com/37433e19f07e441adf368d1bbcad78e6
Maybe try to return res.send as you use async/await and it returns promise
I changed the structure of the app and I do now receive cal events when I hit one of my endpoints, but receiving other kind of error now, anyway this one can be closed.
Cross-origin request blocked, origin 'null' no access

How do I find out when a twilio call has actually been answered when using the JavaScript SDK?

I'm working on an in-browser call-centre application and am using the Twilio JavaScript SDK to achieve this. I'm using these instructions to get integrated: https://www.twilio.com/docs/api/client/device and specifically the example code.
When somebody starts the call I want to display a 'calling' animation, however whenever the person answers I want to change this to display a call timer.
From playing around with the SDK, I can only get the following method to fire when the actual call starts (not when they've answered):
Twilio.Device.connect(function (conn) {
});
Twilio developer evangelist here.
As John Ambrose says in the comments you can't get this directly from the JS SDK.
However, you can opt to receive a webhook callback when the call is answered. You can choose when you get those callbacks using the StatusCallbackEvent parameter, or you could receive all the events and check for the current CallStatus of the call.
When you get that webhook, you would then need to push that to your front end using server sent events or web sockets.
Let me know if that helps.

How to get List Of Connected Users in Google Plus via phonegap

My project requires me to get the list of connected users to the account.
I saw that i can do it using this
GET https://www.googleapis.com/plus/v1/people/me/people/connected?key={YOUR_API_KEY}
however, im having problems on how to supply YOUR_API_KEY
I tried this
https://github.com/EddyVerbruggen/cordova-plugin-googleplus
and was able to acquire the oauthtoken but it doesnt appear to be the api_key.
note : obj.idToken is always null so im only able to get the oauthtoken.
if someone could point me in the right direction that would be a great help.
Thanks,
Jay
There is some mistake in documentation. You need to use webApiKey param instead of webClientId. Look at GooglePlus.java in your Cordova plugin directory - how your JS params are put to Google Api.

Twitter JS API, update status

I'm at a total loss here. I believe I'm right in thinking there is no longer any JS API for twitter which just sucks hugely.
However I realise looking at this I could just use ajax and react to the responses from this:
https://dev.twitter.com/rest/reference/post/statuses/update
OAuth Signature Generator
Example Request POST
https://api.twitter.com/1.1/statuses/update.json?status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk
However when I post to that url I get the following:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
Bad Authentication data -> this is very self explanatory: Your Authentication is Bad; in other word, you are not authorized to use that API method.
Since you use POST method, make sure you set your APP access level to Read & Write.
Sign in to apps.twitter.com, and in the Applications Management page for your app, click the Permissions tab. There you can change your access level.
For further reading, please see this answer.

Categories

Resources