Android Notification through PHP MySql - android

I want to implement notification of news or article in Android.User can put the new article or news on the server after that i want to show notification in my app through PHP MySql.Can someone help me how to do this.Thanks to appreciate.

PHP is a server side process - it only runs when a user/app/service requests the page.
MySQL is a server based database. It's not "connected" to your app.
Your app must then "poll" your website (it has to request data from it periodically). This is best done using an XMPP type service. You can find a lot of info on XMPP - basically, it's complicated to setup and run. It probably isn't worth doing unless you've already done it.
Alternatively, you can use an existing XMPP service. Google Cloud Messaging (GCM) is an excellent option for most Android devices (any that has Google Play installed... so, it won't work on an Amazon Fire phone, for example). It's not "easy" to setup, but they do a lot of really hard stuff for you. Also, there are a lot of references for setting it up, like this from Google:
https://developer.android.com/google/gcm/client.html

You can use Google cloud messaging to display Notification or You need to create a service that always ping your server for new message.
please try 1st options its better.(2nd options is worst because it use more battery & internet data )

You can use google cloude messaging service to send notificaion 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/

You can use GCM (Push notification) and implement the notification generated method inside onMessage method.
For reference use this linkAndroid Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL

What you are looking is Google cloud messaging.
For Gcm you have to write a server in your case is php server.
For Gcm server code or for testing purpose refer this link.
Android: Test Push Notification online (Google Cloud Messaging)
But firstly it is best to learn about GCM itself and it's mechanism.
For this you can refer this link.
https://developer.android.com/google/gcm/index.html
You have to do some settings in Google console which are all explained in this article including the android side code.
Hop i helped you.

Related

How to build a server for GCM

I know how to implement GCM in my App but I don't know how to build a server able to send notification to ALL the users.
I need something quite simple (just sending notification), could you advise me any services and tutorial in order to set up the server?
I wish something not to complex, because everything that I will need from my app is receiving whether simply notifications to display or to tell the app that some new data is available for downloading.
Thank you!!
Prerequisite for GCM Application
Google API Server Key
GCM RegId of the Android Device to communicate via GCM
If you get clear concept about GCM, please visit here
If you want to use java for server side then visit my answer.
Related Links:
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
Android Warriors
If you're using PHP, you could use this approach to send GCM message to your client refer this
You could setup your own local server on PHP using AMPP. refer this
Probably, the simplest way is to add a cloud endpoint module refer this. Then, write a simple service refer this that sends the messages. Finally, let Android Studio deploy it.

Is Google Cloud Messaging Service required for push notifications

I am looking to create an Android app that uses a MySQL database located on a server. When certain changes are made to this database, I'd like a push notification to be sent to some app users. My question is, is the Google Cloud Messaging Service required to implement this? This page http://developer.android.com/google/gcm/index.html seems to suggest that using the Google Developers Console is also required. If so, is it possible to export this project into Eclipse? Thanks in advance.
My question is, is the Google Cloud Messaging Service required to implement this?
Yes and no, if you want to do real push messages then yes it is required however if you dont want to use GCM you can use XMPP to send messages to devices
Push notification can be generated using alarm in android.See this.
But here you are looking to send push notification after certain changes in your database which is located in your server,for that GCM will be a better option.You can find an excellent tutorial of GCM here.

Android phone-to-phone notification over the internet

I would like to develop a small application which can send notifications or communicate from one phone to another over the internet.
Could any please suggest me how can I start with this project?
Look for Google Cloud Messaging: http://developer.android.com/google/gcm/index.html
There's considerable setup. You need to activate GCM for your app in the developer panel, get yourself an API key, and depending on use case, maybe you'll need an XMPP server as well.

Communicate between Android phones using GoogleCloudMessaging

I'm new in android development. I'm trying to develop an app in which a user can send a request to another device running the same app and it should return a response/notification to the sending device.
I googled it and found that GoogleCloudMessaging can be used for that. But all the tutorials say that it can be used to send messages from server to apps. I need to know how the reverse can be done, ie send messages from app to server..
Please provide some tutorial.
Any help is appreciated.
Thanks..
If you want to send data to your server, you can use rest communication.
Here a tutorial
Step 1: Call a server side script*(REST api/ Webserices)* from your android application using HttpPost/HttpGet,
Step 2: Wait for response coming from server and use it.
Note: don't forget send all needful data for your request from your app to server by httppost.
Go through these link this will help you.
Get started with push notifications in Mobile Services.
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
.
Google android doc on GCM,
Google Cloud Messaging GCM for Android and Push Notifications

Instant Messaging on Android with Google Cloud Messaging

I was just looking at the new Google Cloud Messaging (GCM) and I was wondering if it is possible to use GCM for Instant Messaging on your Android application?
I saw you can send data, like a message, from a server, but is it also possible to send from one device to another one?
And how would this work?
Some example code would be really helpful..
Tnx!
The official docs on Google Cloud Messaging for Android does mention that GCM can be used to develop an instant messaging app.
...or it could be a message containing up to 4kb of payload data (so
apps like instant messaging can consume the message directly).
So we went ahead and created an instant messaging app using GCM. The server-side is powered by Google App Engine. You can read the complete tutorial here. Create an Instant Messaging app using Google Cloud Messaging (GCM)
So it is possible to use GCM for Instant Messaging on Android, to answer your question. However, reliability of GCM compared to XMPP for IM is another topic.
Just my two cents:
I think you should not use GCM for delivering IM. You should have a dedicated server where your Android IM apps will connect to, using a persistent socket connection. Your server will know who is online or not and therefore can present an 'online list' to all the apps.
GCM can come into play, while users are offline or not running your app. A GCM message can be sent to them to indicate 'XXXX wants to chat'. They can then launch your app and automatically connects to a chat session.
Google has said that the delivery of GCM messages are not guaranteed. This reason alone is not a good idea to rely on them for Instant Messaging.
Try pub nub - it is pretty easy to implement - send Im from one mobile to another - simply fire up the web page (see link) in the browser , and chat between pc, mobile - and works - with 'no server'. Code is for javascript but they also have java. Chat app using jquerymobile web app framework
You might want to check out how a server sends a message to the GCM Service. It is possible to use php on Server side so it should be possible to adapt that to a POST request directly out of your application. However, to communicate you need the registered ids of the devices you want to send data to. Means you will need something to store and get them. Best solution would be your own (web) server which stores all ids and handles the Message sending.

Categories

Resources