I am building a simple app with Laravel 4 as backend, Angular JS as frontend and MySql.
So far, i am using long polling for any update in database, for this i have to fire $http request from client to server after every 5 minutes.
I need something like Push Notifications which notify a client server that there is an update in database from server side.
I've searched a lot of things but just found Push Notification for Android and iOS only.
Is there any Library or Method available to implement Push Notification for Angular JS in Laravel 4?
Help Please, It would be appreciated.
The best solution would be to use WebSockets. I suggest using Ratchet (WebSockets for PHP). There is also the problem of WebSockets browser support which you need to take into consideration (but that can be overcome by using the websocket.js polyfill).
Related
I am new to the Websocket world. I have implemented 2 API's one for getting the comments and one for posting the comments to a post. Using the following technologies.
Laravel 5.7
http://socketo.me/
Vue + Echo
Following https://www.youtube.com/playlist?list=PLwAKR305CRO9rlj-U9oOi4m2sQaWN6XA8
The above WebSockets are working fine with browser to browser in Axios calls, my question is how can I write WebSockets for Android/iOS developers and test like we do for API's and use postman for testing.
I have looked into iOS developer code they were using something like ws://123.123.123.123/socket Please guide how can I convert my WebSockets as ws: and deploy to stage server?
How to make a WebSocket on the above-mentioned technologies that iOS/Android developers can use directly?
I am sure my question looks basic, guidance can change it :-)
I want to send coordinates(lat,lng) from one device to another device as the location of the rider. If I am not wrong one device will push and another device will listen?
How can I write those WebSockets calls?
I want to add real-time chat with notifications to my Laravel project.
How can I do that and also save the chats in MySQL? Is there any chat framework that I can use??
Because the best way to implement a chat uses websockets, which are not supported by default in PHP you need a service like pusher or running a Laravel Echo server which is based on socket.io (a Node JS lib).
Pusher is something like "websockets as a service" and has a tutorial: https://blog.pusher.com/how-to-build-a-laravel-chat-app-with-pusher/
And then there is this demo:
https://github.com/jplhomer/laravel-realtime-chat-demo
If you cannot run or pay for any of the previously mentioned websocket implementations, you could consider using long polling in javascript, but that is a worse solution. It takes more resources and works far less better.
Web Chat Application using Long-Polling Technology with PHP,MySQL and jQuery
I have a chat feature in my app using JSQMessagesViewController (https://github.com/jessesquires/JSQMessagesViewController).
It makes an API call to my server every 5 seconds to get all the chat messages between two users to populate the chat view with those messages. It was suggested I turn that into a socket connection because making an API call every 5 seconds will be hard on the battery and a waste of API calls.
How do I turn my chat feature into a socket connection with my server?
Are there any libraries in Objective-C that will help me accomplish this? And also, I'm pretty sure that I'll have to set this up on the back end too, so are there any resources as to how to set this up on a PHP Laravel backend?
You should be able to accomplish this using a couple mature libraries on both the iOS frontend and the PHP backend.
iOS: SocketRocket
https://github.com/square/SocketRocket
PHP:: Ratchet
http://socketo.me
They both support RFC 6455 so should integrate pretty easily.
Since you are using PHP, I'm going to take a stab and guess you are using Apache? If so, here is some more information on setting up websockets to work with Apache which can have issues with connection management: Setting up a websocket on Apache?
I'm new to websocket and realtime applications and I would need some clarifications.
I developed an application for a customer that involve some users and product data.
It is a PHP web application running on the internal apache server.
The client side of the app is based mainly on JQuery, and for some parts usable from tablet devices we used JQuery mobile / html5.
Now the customer is asking to add some messaging/notification feature in this way:
a user will be able to post a message about a product and the web console of the other users must be "showed" a realtime notification. We are thinking to add something for example in the header of the page to notify that new messages are present.
I made some research and as all the app is already built in PHP I was thinking to go for Ratchet. Is this a good idea?
If I understood this well, I will need to install on the server also the ratchet server components and use for client side integration something like AutobahnJS library; is it right?
Has anyone already built something like this?
Is there any problem communicating between Apache and Ratchet server?
That okie,
I tried use Ratchet/AutobahnJs Websocket, that's awesome. But I have (special?) problem :o in here.
In your case, I think you can use AJAX, it's simpler than Websocket. You can "zip" multi-notifications in to 1 response and request server every 5 seconds.
Yeah it's a good way to go about it, ajax leaves you with a lot of overheads. it's pretty simple to get going with ratchet and it will give you the ability to send notifications in real time, as well as the notifications it will allow you to edit the page as well, i.e change counters/ icons / message count etc, basically same as ajax only in realtime and no need to poll for new data.
It also means you'll be learning some new stuff which is always a bonus, for this alone i would do it.
Hello there and happy new year 2013!!
I returned to my app after vacation, and now I want it to keep alive and hearing for updates!! Does anyone knows how to do so? I don't mean a complete answer, I mean like guidence, orientation!! Because I don't know how to start doing it!! And on the other hand, how do I send the updates from my PHP/PostgreSQL server? Has anyone did something like this before that could help me?
Thanks in advance!!
If you want to PUSH updates to your application, you can do so using GCM: http://developer.android.com/google/gcm/index.html
If you can simply have your application POLL for updates periodically, then you can use AlarmManager and an IntentService to have your application hit your PHP endpoint as needed.
The choice of which to use usually comes down to how timely the updates need to be and how often they are likely to occur (taking into account battery, network, and other resource usage and so on).
To get started with GCM using PHP check out: Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
And, here's a good example of AlarmManager/IntentService (and handling wake locks).
My advice is to use GCM to send push messages to the device the app is running on, simply because the GCM service is always running and it will use less battery than polling.
As a side note: donĀ“t send the actual data via push notifications, instead just send a notification that there is new data on the server. The app can then download the new data from the server.
If by update you mean and update in version that is a user has version 1 of your app but there is version 2 available then you could do it like this :
You could have a variable that would save the current app version, then every time the user starts the app you should connect to your server to check the most up to date version. You then can compare and show an alert if the user has a lower version than the one you currently have in your server.
Two important things here : Every time you update your app you should look for the value of the version variable and change it and you should have the current app version variable in your server updated as well
If you mean updates in the data then your best bet is to use the GCM service (Google Cloud Messaging)