JavaScript - Button Click to send data remotely - javascript

I have a list of company tablets (Android) that are located all around the United States. I would like to be able to select one from a list, compose a message, then be able to send the message to the selected device. Some locations have multiple tablets on the same network, in which i'd like to send to all of them at once if possible.
Is it possible to send data over the internet via JavaScript to an android device, or a list of devices? If so, how can this be done? Is there a certain term for what I am trying to do so I may google this for better results?
I apologize for my lack of knowledge and terms.

There's two options you have:
1. Use websockets to send messages to active devices
In your backend system (you need one) keep a list of active connections. In your webpage, display the connections. Select one, and in an input field type a message. Send this message to the backend, e.g. form post, and send this message to the corresponding connection. In your active device, have an app working that listens to the socket and displays the message.
2. Use Push notifications
You can easily send push notifications to android devices. However, you need a working app on a device before you can send it pushnotifications. Firstly, the app needs to register itself at GooglePlayServices, there's a ton of tutorials on this. Then this will give the app a deviceId, which it needs to send to your backend. In your backend you keep track of all deviceIds in your database.
The same principle holds for alternative 1: display the deviceId's in your listbox, and send it together with a message to your backend.
In the backend send a push notification to the device. There's also a ton of tutorials on how to do that (you need to set up a project in Google to get an API key, which is really easy).
There are probably other alternatives, but these two are the most easy I'm sure.
Also, in order to group send notifications, group devices by their external IP. Make the devices register themselves to your backend so you have their external IP, then group them by that in your database. In the frontend now select an IP instead of a device.
EDIT by FoxDonut (Asker)
I also asked, in the comments below, if it is possible to use push notifications without uploading my application into the Google Play Store. The answer is Yes. Please see this post for clarity.

Related

AJAX - How can I build a notification system, that is constantly getting updated, without slowing down my website too much?

I am a beginner to web development, and I am trying to do a notification system with AJAX and jQuery.
In my web application, I have a comment system where you can mention another user. After a comment mentioning a certain user has been written, a new entry on my notifications table will be added, containing the comment, the id of the user who commented and the id of the user(s) who will receive the comment. After the notification is stored in the database, I want the person that was mentioned to receive the notification.
To that effect, I decided to use AJAX. Using the setTimeout() method, I am sending an AJAX request to the database every 2 seconds, and with that, I can display the notifications visually to the user that is meant to receive them.
My only concern is that this will slow down the site once I connect it with a server.
So, I was looking for a way that would allow me to implement a notifications system without slowing the site too much, since the one that I am using currently doesn't seem very efficient.
I would appreciate any help.

Real-time sockets between Android and server

For learning purposes I’m creating an Android app that does the following:
When a person arrives at school, he/she can check a button in the app and he/she is added in real-time to a list (in the server database) of everyone that also checked “at school” button within the app. He/she can also add a message before clicking the button.
The rest of the students then receive a toast in real-time with the person’s name that arrived and it’s message.
I know how to do the Android part, but what is the best way to do the real-time event queries and requests in communication with the server? For example, I send a socket with the persons confirmation, location and message to the server. From the server-side, I supose there’s a nodejs controller that receives the socket and updates the database in sql. Then it sends a socket to every client online and a confirmation to the checked client.
Is this the “professional” way to handle data like this? What is the best (fastest, more secure, standard) way? When I Google how to make this communication I can only find web server client-server communication with Apache, but I’m really looking for a real-time event with an Android app.
I’m not really looking for code but to know and understand technologies and design patterns on how this can be done. And what to search for in order to learn how to do this.

Sending RealTime Notifications Based on Location in NodeJS

I’m building an app with some location-based requirements. One of the requirements is to send the user a notification whenever the user is at a specific address (think of it like how the Apple Wallet app sends you a notification whenever you get close to, say a Starbucks location).
How would I go about building this kind of functionality? I’m aware that this will require using WebSockets. But, like, how would I do this exactly?
Do I just have the client send his geo coordinates to my backend every time it changes, then compare that to a desired destination saved on a database? Or, is there a better way?
Thanks.

How to include send message and inbox option in a Node.js web application

I want to add a send message and inbox option in my node.js application. Basically the website is all about posting jobs in the forum, where three types of people can search and post jobs according to their profiles. Three of them are freelancers, mentors and clients.
So in order to them to communicate with each other, is there any way i can include a chat option in each of their profiles, so that they can send messages to each other.
I have also checked the option of Socket io for chat application, but i am little confused that whether is it a right solution according to my requirement or not.
socket.io will allow for realtime chat communication like gmail's 'gchat',
so socket.io would be a relevant solution to your problem.

Creating my first Mobile App and connecting it to a database

I have to create a Windows Phone 7 app as part of a research project. The app needs to:
Allow the user to login by connecting to an sql server database (stored locally for the purpose of this project)
If login successful, return a list of products associated with the user (i.e. in product table where UserID=x)
User can click on an item in the list, and then add photos for that item. This can be done offline as well (using HTML5 offline storage)
When an internet connection is available again, user can click 'Upload' (or automatically synced, but not necessary) and the images are all uploaded to the Images table with the correct ProductID as Foreign key
Since this is the first time I am doing any mobile programming, I am not sure what is the best approach. I am especially unsure of how I am going to connect to the database. I'm not really interested in learning Silverlight, so the app should use mainly HTML5 and javascript, I also am looking into JQueryMobile.
I have already installed PhoneGap and am trying it out, but my main concern is how to connect the app to the database as I am having trouble finding the 'proper' way of doing this e.g. using some kind of web service or directly through javascript (read it can be done but is not recommended). If anyone could recommend or suggest a good approach of doing this that would be great!
SqlServer is only available on the phone via LinqToSql which you need to expose via a service or a DAL. I dont think that its possible to make calls directly from Javascript to LinqToSql on the phone.
If you're not set on the idea that the DB needs to be on the phone, you can just make service calls via ajax to a server and access the db that way. I recently did a blog post exposing a db via a WCF Data service and consuming it on the phone. It doesn't cover calling it via ajax but should help get you started.
http://www.ritzcovan.com/2012/02/building-a-simple-windows-phone-apppart-4/
If you want to store data within the WP7 database, use the PhoneGap storage APIs.

Categories

Resources