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)
Related
I am new to swift and was wondering how could I send commands from a server to my iOS application ? For example imagine a website where I can click a button and that button would then trigger a pop up to all users of my app. Is this possible and if so can someone lead me in the right direction?
Much appreciated
Yes, you can
Silent Push Notification: Send a Silent Push Notification and handle in your app. But you need user permissions to receive Notifications. Add "content-available" : 1 to your notification content.
Using Sockets: There are many options to create connection b/w device and server. example: https://socket.io/
It depends what you are trying to do, you might want to look at apple push notifications and see how they work. From there I would suggest looking into sending notifications to the apple server (that would send the push notifications to the app). I hope this sends you in the right path good luck!
I just assume that you have an application that a number of users are using and you have a web application that can show all mobile users.
For the most of cases, whenever a user is using the application, you let the application send a request with your user's information to your server and your server records the user information in the database.
When your website wants to show all the users' information, it just fetches all the information from the database instead of sending sort of commands to all applications to get information in real-time.
Of course, there is a more complex way to send commands to all running applications to get the results. However, it requires both server-side and client-side (ios application) implement functions sending commands in real-time using Socket or MQTT etc. This is more complex and it requires iOS application running in front or background at the same time.
I assume that using HTTP to record every mobile user is more suitable for your case.
I am trying to code a messenger service that will store sent messages in a server and then push the message to all devices connected to the server.
The messenger will be used in a classroom environment and the messages will never be sent to one individual device. At the moment a message can be sent and stored in the database but the app needs to be refreshed for all the messages to be displayed. A simple way would be to continuously run the stored procedure but that would require extra bandwidth and i'm sure there is a better way to do it.
I am currently coding in Android Studio and I'm using MySQL as my database and PHP for my stored procedures. I am very new at Java and this type of coding so any help will be appreciated.
Thanks
Yes, what you are suggesting is named "polling" => check if the server has some updates each 10sec or something like that. You're right, it's evil (drains the battery, use a lot of bad=ndwidth, etc.)
What you need is a "push" service. If you are working with Android, the easiest way of doing it is to use GCM (Google Cloud Messaging) : http://developer.android.com/google/gcm/index.html
This little guy will provide you a way of notifying all the devices that theure have been some changes on the server.
It's pretty well done (if it can't reach the devices, it will try again with an exponential time delay, etc.).
You can use google cloud messaging service to send notification in device so please register your application on google service all step are cover below link.
Open below link and follow step
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
I'm Just developing IOS App, And i can easily post data from the Iphone to server and get the response back..
The problem starting when someone update values in the server side (From a website), And now i have to "post" the changes to the iphone and update the table changes - there.
Is there a way to communicate from the Server to iphone to transfer data? I thought to use push notifications, The thing is that i don't know if i can trust it (What if the app is not running? i don't want to notify the user that he made changes, i simply want to update the iphone so it will call a function that will update its tables..)
The Server language is PHP.
Hope it clear enough..
Thank you!
Eran.
There are two things you can achieve:
Let the iPhone app request the server data with an interval (polling, e.g. every 10 seconds). This is only useful if the updates can be forwarded with a small delay. Another drawback is that your server load will be a bit higher because of the many requests
Open a socket between the server and the iphone app. You can use CocoaASyncSocket for this. You can send messages to your iphone app every moment you want. If the iPhone app is closed, you can close the socket connection and the user won't receive updates anymore
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.
I need to make chat application for android. I thought of using PHP script to implement the chat application. Basic idea is to send message form android client to PHP script and making use of PHP script send the messages to the MySQL database. These messages will be broadcasting to other people. But the problem is auto broadcasting messages to other people. Is there a way to do this using android and php?
You can do the following
Make a persistent tcp connection between your device and the PHP server
When a message is broadcast send it over the tcp connection of each device
On the device process this notification and you are good to go.
If you want to use Java on the server side I have your project already finished and ready to ship ;) (just kidding)
But if you are interested check out the Device-To-Device messaging framework of OpenMobster Mobile Cloud platform. The project is free and open source. Here is a link to the Device-To-Device Framework: http://code.google.com/p/openmobster/wiki/D2DPushFramework
and http://code.google.com/p/openmobster/wiki/PushFramework
The above three steps are already taken care of by the framework. The developer just has to focus on the App itself
Good Luck!!!!
Yes there is several ways to do this
you can just post to the server and from the server send push notifications to the mobiles
You can make the mobile keep checking for updates if it exists
You will require to finish these steps ( at least ):
setup a PHP web server
register for Android Push Notification (you probably need that)
create database schema
write your own codes to allow users to submit & retrieve chat messages
security !!!
You'd probably want to use Google's C2DM, though it's not free.
Your php server would get a message from a phone, do it's processing, then make a HTTPS request to Google's C2DM service, which sends the messages to the destination android device.
http://code.google.com/android/c2dm/#push-process
Don't use C2DM, its a deprecated. Please go through the GCM(Global Cloud Messaging),
please follow this link,
http://developer.android.com/google/gcm
Have you heard of Firebase? Firebase. Making a chat app with Firebase is like eating pizza.