Push Notification from Web based application to Android - android

I have developed web based application using yii2 framework and MySQL database and my plan is i want to make an android app that can receive notification from my web based application real time and can pull data from it too. but i'm not sure how can make it works and using which methods i can implement this. can you give me some advise and source to learn it?
thanks

You have to follow below steps to implement push notification
1) You have to register on google developer consol
https://accounts.google.com/ServiceLogin?service=cloudconsole&osid=1&passive=true&continue=https://console.developers.google.com/dcredirect/
2)enable the GCM api from api list that available in api lists further instruction you will get on site when you create account.
3)Generate key for GCM web/ android.
4) Use this GCM key from android app and write the the GCM notification receiver
program in android app and using notification manager show on notification bar.
5)Using server side key you can write the program to push notification from web site.

Related

what is best way to communicate between asp.net website activities and android app?

We have a asp.net Web application which has functions of user activities like notification,messages,etc.
And we have a native android app for this web app as well.
Now we have to make functions of user activities like notification and messaging.
For eg. User A likes or follows User B or does any activity which will give notification to User B.
notification or messaging system like facebook. in which if you tag your friend in some activity or like your friend activity then your friend will know via notification in android app as it shows in website
What will be best way or efficient way in android to detect the user activity and get the push notifications get going.
i have done bit of research but not getting the correct idea/track.
i have got some like
1) Android Push Notification using Parse
2) Android Push Notification using GCM
3) Android Service BroadcastReciever
3) Android Service BroadcastReciever
Pros:
no need to change anything in your website API. Your simply download friend's activities each N minutes and check if there are new one.
Cons:
battery will be drained very quickly
your messages may have some delay between activity and notification about
Do not use this approach.
2) Android Push Notification using GCM
Pros:
easy to integrate (mobile)
free of charge
Cons:
no nice looking form for sending push (only from the code or http-request)
works only on the devices with Google Play Services
requires additional work on the server (storing user's ids, sending pushes)
1) Android Push Notification using Parse
Pros:
easy to integrate (mobile)
no need to do on the your server (except initiating push)
it have own solution for Push-notification for devices that doesn't have Google Play Services
you can send Push from the developer console
Cons:
paid (but have some free limit)
require some setup and coding in the parse console
My opinion:
If you have your own server(and database) use GCM. Integration with Parse doesn't worth it.
But if you have a lot of users with phones without Google Play Services it make sense to look at Parse.
Use Ksoap2 to communicate between ASMX webservice and android.
you can check the following link that have an example how can use Soap Webservices in android application:
https://programmertoolbox.wordpress.com/2013/04/07/communicate-between-asp-net-webservice-and-android-app/

Push Notifications in Android using Google App Engine

I am currently developing an app where users create posts that are stored on a server. When another user shows interest in a post by clicking a button, I want to notify the author of the post using push notifications. I have already set up the data storage using cloud endpoints with Google App Engine. Is there anyway I can use these endpoints to implement push notifications? If not is there another easy way to implement push notifications given my current setup? I have already read about Google Cloud Messaging on the developers page but was somewhat confused. I have kept track of the registration id's but I don't really know where to go from there. Thanks in advance.
You can use the HTTP interface to the GCM servers as described in this
Android developers page.
The easiest way to do it is by downloading the Google Cloud Messaging for Android Library using the Android SDK Manager, which will give you a jar that handles all the complexity of setting up the requests and responses to GCM.
Towards the bottom of that page, there is a sample Java application for push notifications on App Engine which you can use to get familiar with sending push notifications and then adapt to your needs.

Create push notification in android

how to create push notification in Android using GCM or either C2DM i have tried and check some sites and didn't get exact answer.i need to know how it works.Can any one provide me good tutorial on push notification
Could anybody help me. Thanks!!
Its Depend on your requirement what you have to do.
here is sample of C2DM: in this sample android device is registered wtih server after that server send massage to all device. so there is one way communication(server to Android device)
So all things are done at server side. just download this tutorial. Both Server side(PHP) and Android code are available.
Edited:
you got application key from Google services which you have to put at server side.
SENDER_ID – Google project id which you have to send when you want to register your device with server.
You can use GCM demo app supported by Google. One needs to install GCM libs using SDK manager and then create API keys in Google APIs console. Follow instructions from the link and you can create an app that receives push notifications from GCM server. I did try this and it worked even on my Android emulators. You need to use Emulator that targets Google APIs though.

Implementing one to one and group chat in android [duplicate]

This question already has answers here:
How to make a chat application in android? [closed]
(6 answers)
Closed 9 years ago.
I am developing an Android app in which I have to implement chat messaging. I would like one to one chat or a group chat.
But I have no idea how to start. Please help me with this stuff. Any help will be appreciated.
A simple chat mechanism will have 2 basic functionalities
Send the message to server (with info about the recipient)
Receive the message from server (designated for my user name)
First step is simple, we can create a web service which will accept the message with additional information about recipient(s). We can create it using any server side language.
Step 2, that is fetching the message from server can be done using 2 techniques, Pull the message (using polling) from server, or Push the message from server to android phone
Polling: In this, the android device will keep accessing server after a few seconds to check if there is a message available for user. This again can be implemented using a simple async task at the client side which will keep calling a web service after say 2-3 seconds. This is fine to use if we are planning to enable chatting only when user is accessing the app (no notifications like gmail or facebook), so that we can kill the polling service when not in use (otherwise it will eat up resources).
Push notifications: a better option is to use push notifications. Android provide Google cloud messaging or GCM (http://developer.android.com/google/gcm/index.html) which will help achieve push from server easily. Otherwise you can try a third party API like urbanairship or pushwoosh depending on your requirement. Push notifications will help the user to receive messages even when he is not using the app.
So in nutshell, a webservice to receive the messages and a push notification mechanism should be sufficient to implement a chat service in android.
Little bit about UrbanAirship
I used UA in one of my projects for push notifications as I needed to support both iOS and Android. If you just want to support Android GCM might also be a good option.
Coming back to UA, check this for sample code and usage: https://docs.urbanairship.com/display/DOCS/Home
The way it works is simple, when someone installs the app and is connected to internet, app registers itself to the UA service. A unique code is specified for each installed app (this is the time when you can capture the user name and unique code and store somewhere in your DB). Next UA provides an API using which you can push a message to designated recipient(s), using the unique codes which are available with UA. These messages can be received by android app and used as per the requirement. Even if the app is not running we can show a notification just like when we receive an email or a message
You can use an existing platform like Scringo. It gives you a one-on-one chat as well as group chat (both the client and the server) as well as the push notification service.

Set Push Notification in android

I have an Api. Suppose this api http://api.androidhive.info/contacts/ has this contact which I'm displaying in list view. I want to set a push notification in our application, such that when ever a new contact is added in the api then there should be a notification in our application that a new contact has been uploaded. This Notification should be displayed even if the application is not open or launched.
For example: It should function like "Time of INDIA" android app. When news updates come then it shows a Notification.
I am new in android. Please help me. hHw i will do this? Please send me example sources or post me related blog or tell me logic. How i will do this i have server access also.
Thanx
You can use GCM for this,
Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices. This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly). The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device
This document describes how to write an Android application and the server-side logic, using the helper libraries (client and server) provided by GCM.
Check these links,
http://developer.android.com/guide/google/gcm/gs.html
http://developer.android.com/guide/google/gcm/demo.html
http://www.basic4ppc.com/forum/basic4android-getting-started-tutorials/19226-android-push-notification-gcm-framework-tutorial.html
http://fundroiding.wordpress.com/2012/06/29/google-cloud-messaging-for-android-gcm-simple-tutorial/
for client side app you can find the code here
https://github.com/marknutter/GCM-Cordova

Categories

Resources