Push notification in Web pages - angularjs

Can a web notification be implemented in web sites? I'm using a environment of jsp's with jquery, vue and angular.js for the front side. There's a way to implement web notifications with this environment?

You can use the Notification API to achieve this.
If you want to use Service Workers to push notifications from a backend, you can check the Push API
These API are still drafts and may only work with modern browsers. Make sure you are using these API's over https.

you can use web socket, which has integrated in Angular already.

use for example:
https://github.com/mqttjs
then in your js:
this.client = mqtt.connect(url, options);
if(topics.length>0)
this.client.subscribe(topics);
this.client.on("message", (topic:any, payload:any)=>{
console.log('CONNECTED', payload);
});
this.client.on("connect", function (connack: any) {
console.log('CONNECTED', connack);
});
And use some server side message broker eg: rabbitMQ or other message router
read this
https://www.rabbitmq.com/web-mqtt.html

Yes, Web notification primarily targeted for Web application, client side registration and server sider processing for pushing the notification, below site has both client and server side examples -
ServiceWorker

Related

How to consume external API with server side in ReactJs in one project?

I want to consume an API of a company, and this API could not be consumed with a Client Side Script such as Javascript, I want to use react js to consume this API on the Server Side but on the same project.
I asked the owner of the API and I receive an email :
It is not possible to use our API request in a client-side language script such as Javascript, it must be used in a server-side script.
How can I do that ?
Thanks !
As far as I know, you have to options:
create an API that works as a proxy and this API calls the other API (so, the proxy-api is called by client/react and the second API is just called by the proxy-api
use server side render in react (you can see more about this alternative in: https://www.digitalocean.com/community/tutorials/react-server-side-rendering)

How to track a service whose response is keep changing after a minute in angular JS?

I am working with angular js (1.x).
I need to display some data which is coming from backend. For that I am calling a service.
Problem is that the response keep changing periodically. But still I didnt use setTimeInterval as this may overload backend due to continuously sending request from UI. So I let user to manually refresh the page to update the data.
Is there any way in which I can auto-update the data without having to use setTimeInterval?
What is a websocket?
WebSockets is an advanced technology that makes it possible to open an interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
Src: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
AngularJs + Websockets
You can use ng-websocket for angularjs
https://github.com/wilk/ng-websocket
or
AngularJS WebSocket Service Example

Sending notification from nodejs server to angularjs

I have an angularjs module deployed on a nodejs server. The nodejs also has an REST end point.
Whenever I get a hit in the nodejs REST end point, I want to update a scope variable in angularjs script and then I have to redirect the user to a page after that.
I thought of using event emitter, but i couldn't do that since the event emitter require response.write, and I couldn't redirect to the page after this.
Is there any way I can do achieve this ?
You should use EventSource to send notifications to client. It's built for that purpose. You can use EventSource package for that purpose in Node.js.
You shouldn't redirect the client from the server, if you're using Angular's routing. Instead let the Angular Router redirect after it receives the push notification.

Debugging web API back-end and angular front-end as two projects in one solution

I have one solution in Visual Studio 2013 which contains MVC Web API and Angular app.
I have set Multiple Startup Projects so both projects start in the same time when debugging.
The both start OK, but they are running on different ports so there is no way for front-end to call api from back-end.
front-end has request look like this:
$http.get("api/MenuItems").then(function(response) {
//do something here
});
and backend has controller like this:
[RoutePrefix("api/MenuItems")]
public class MenuController : ApiController
{
public IHttpActionResult Get()
{
return Ok(MenuItem.GetItems());
}
}
How do I debug this? I would like to set breakpoint in the controller of the Web API and see the debugger stop when fron-tend fire up request, but this never happens ... Am I missing something?
This was inspired by tutorial AngularJS Token Authentication using ASP.NET Web API 2, Owin, and Identity
Source code for the tutoprial is tjoudeh/AngularJSAuthentication
Because they are running on different ports, you have to specify the full url. A full url goes http(s)://host:port/address
So if your backend server was on port 80, you should have your api call
http://localhost:80/api/menuItems
When a url is relative it will go to the same host so if your frontend was on port 40, /api/menuItems refers to
http://localhost:40/api/menuItems
Then if you are debugging web api and you put a breakpoint at the start of the controller function Get() you should be able to debug the request
There is an article for similar to this.
https://weblog.west-wind.com/posts/2011/Dec/15/Debugging-ApplicationStart-and-Module-Initialization-with-IIS-and-Visual-Studio
Basically if you want to be able to debug AngularJS and MVC server side code at the same time(F5 in Visual Studio), you need to configure the website in IIS. So serverside and client side can call the same domain(not with the port).

Is it mandatory to use Kony middleware for Kony application?

I am creating a Cross platform application using Kony Studio. We are having our backend and web services ready.
Can we consume same services with out accessing Kony middleware?
If yes, can you please help with some sample code and tutorials.
We can call consume the services without using the middleware using the HTTPRequest API
var request = new kony.net.HttpRequest();
request.onReadyStateChange = callbackHandler1;
request.open(constants.HTTP_METHOD_GET, service_url);
request.send();
You will get the result in the call. Go through the documentation for complete details.
To consume web service directly from Kony without using middleware, web service response should be in json. Otherwise, it should go through middleware.
To consume the service otherwise you will have to go for an FFI implementation. This will lead to separate implementations for the different platforms that you are targeting. Therefore you should use the Kony middleware.

Resources