send notification to android device from server without GCM(Google Cloud Messaging) - php

I have to send notification from server to android device. I developed application which got notification from server by using GCM (Google Cloud Messaging). But as I already have server then why to use GCM. I am not getting the purpose of using GCM. Can we send notification from server to android application without using GCM.

General Communication Pattern :
Device --> HTTPRequest -- >Server , Server -->HTTPResponse --> Device
But in this case, the device gets a response only when you send a request from your device to the server. Hence, whenever you need something new from your server you need to make a
request.
Using GCM, you do not need to make this request explicitly to your server. You'll automatically be notified when something new happens (depending on your implementation).

You are having server but GCM is totally different thing then your server.
GCM will monitor Your Application server that any changes made or not ??
And if anything created then it will send you notification without refresh or reload the Application.
and GCM will send you notification when your application is not working as well

Related

Do not send push to users who no longer have the app?

I have a GSM PUSH panel and it happens that when user installs the app I record his id to send future notifications.
But after it uninstalls I continue with the ID of it saved in the database and whenever I run my routine, it sends the push to those users even without having the app installed.
The problem is that I already have thousands of id's and now it's taking more and more to send.
Is it possible to know who does not have the app installed anymore and put a flag in the database so it is no longer sent?
Example of JSon return:
{"multicast_id":5157270514039936452,"success":2,"failure":1,"canonical_ids":0,"results":[{"message_id":"0:1474029083357948%0e3f0485f9fd7acv"},{"error":"MismatchSenderId"},{"message_id":"0:1474029083356778%f17b55e1f9fd7erf"}]}
You have to implement it:(https://developers.google.com/cloud-messaging/registration)
The end user uninstalls the client app.
The app server sends a message to GCM connection server.
The GCM connection server sends the message to the GCM client on the device.
The GCM client on the device receives the message and detects that the client app has been uninstalled; the detection details depend on the platform on which the client app is running.
The GCM client on the device informs the GCM connection server that the client app was uninstalled.
The GCM connection server marks the registration token for deletion.
7. The app server sends a message to GCM.
8. The GCM returns a NotRegistered error message to the app server.
9. The app server should delete the registration token.

Sending data from sever to Android Device

I am using LAMP stack in my server and I want to send data from the server to the android device. The android device should not make a request to the server for getting the data , the server will send the data on its own and the android device should receive it using a background service. What should I do?
P.S -> I know GCM and parse.com do this using push notifications but is there any other way?
In General I can see only three options,
Make time to time requests from device to server
Use Google Cloud Messaging
Use a signal R client for android (if you need to use signalR you should use microsoft asp.net instead of LAMP )
I would like to recommend you GCM way. I haven't use Signal R in android native mobile applications but i have use it in web application development.
I have added some links above, hope it will help you.

How to use websockets and push notifications at same time

I currently run an app in php zend framework that contains a real chat using node.js and socket.io, the chat is working really good, but i need to create a service to send push notifications using the pushwoosh technology, is there any way to send the push messages in the node.js server? or i have mandatorily to create a service in zend framework, considerating that chat is running in an mobile app too, and the messages should arrive even when the app is closed.
thanks for your help.
Sending push notifications on mobile devices cannot be done stand-alone and you must take in consideration that you have to rely on third-party services.
The concept is that you don't directly send push notification to your application, but you send the request to a third party service asking to send the push notification to your registered application.
For example, these are the steps you will go through to send a push notification to an IOS application:
An app enables push notifications. The user has to confirm that he wishes to receive these notifications.
The app receives a “device token”. You can think of the device token as the address that push notifications will be sent to.
The app sends the device token to your server.
When something of interest to your app happens, the server sends a push notification to the Apple Push Notification Service, or APNS for short.
APNS sends the push notification to the user’s device.
(reference: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1)
So it's not as easy as you wish to. You won't directly send the push notification, but you will ask to apple in case of IOS or to Google's server in case of android to send it.
In most case, you will have to register as developer on their dev centers and get all the tokens and certification they ask.

What should I use to develop a simple messaging service in Android application?

I am very new to Android programming and I am trying to make an app that enables users to send and receive messages. I already have a database and Apache set up. I've already implemented login, registration of users and adding friends to chat with.
Now in order to send and receive messages, do I use Google cloud messaging service? But GCM requires to set up the backend on Google cloud, right? I already have a working backend, so how can I use my existing database and Apache server to implement messaging? Should I write a PHP script to send and receive messages to/from Android devices?
But GCM requires to set up the backend on Google cloud right
No you don't need a backend on Google Cloud. What happens is that you use your own server (called "third-party server" in their docs), to send messages to Google's GCM server (using CCS protocol) which relays it on your behalf to the phone.
The same happens in reverse: the phone sends messages to Google's GCM server which relays it back to your server.
Here are the docs on getting you started:
Client implementation
Server implementation

not being able to establish device-to-device messaging using GCM

I am trying to establish device to device messaging using Google Cloud Messaging. I tried using socket programmng, but the connection used to get lost everytime I moved to the next page. Thus I am using GCM. The plan is to send a message from client's phone and it should be displayed on server's phone, using 3g/wifi and not bluetooth.
I am referring the following link for the same:
http://androidexample.com/Device_To_Device_Messaging_Using_Google_Cloud_Messaging_GCM_-_Android_Example/index.php?view=article_discription&aid=122&aaid=142
It has no errors and is running, but nothing is displaying on the screen. Also a few doubts:
In the code in CommonUtilities.java what should be the Server_Url? I am using XAMPP, so should it be XAMPP's URL?
Also, what should be the Sender_ID?
Also in MainActivity.java, what should be the device IMEI? Do we have to enter that manually, or will the device fetch on ots own.
Also in the php files, its written enter "GCM Registeration ID got from device".Is it client's ID? I am running using Google API and registering my ID in the settings of the emulator before proceeding further.
Can anyone please tell me where am I going wrong? Or even if you have a better idea, please do share here. I am looking for mobile to mobile communication only, not using push notifications.
GCM is working as follow:
1/First of all you have to register your application in google and get your Sender_ID
2/the client connect to GCM cloud in order to register it self (using the SENDR_ID)
3/GCM cloud send a registrationID to the client
4/You should make a server so that you save the registrationID of any device that runs your apps
If you want to send a GCM notification from one client to server
1/the client should connect to your server
2/tell the server to make a demande to the GCM cloud containing the registrationID of the server so that the GCM send the notification to the server
you will find a detailed explanation here

Categories