0

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.

Isaac Bennetch
  • 10,266
  • 2
  • 27
  • 38
anju patel
  • 85
  • 3
  • 11
  • Anju, you have to implement Push Notification to achieve this. – Pratik Dasa Nov 13 '14 at 05:48
  • @Pratik :- I know this , But i want to show the notification from through PHP MySql.If some new data add in PHP MySql then show the notification on my app.How ? – anju patel Nov 13 '14 at 05:52
  • And for your problem, it will be possible using GCM (Push notification) only or you have to run one service and you have to call webservice every minute and when you get it you have to set Notification bar – Pratik Dasa Nov 13 '14 at 05:55

5 Answers5

2

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

Jim
  • 9,902
  • 1
  • 23
  • 35
0

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 )

Nooh
  • 1,518
  • 13
  • 21
0

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/

0

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

Furqan
  • 1,407
  • 1
  • 14
  • 21
0

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.

Community
  • 1
  • 1
Nitesh
  • 3,550
  • 1
  • 17
  • 24