How does the communication between app, proxy and google work? - android

I'm currently developing an android application with two versions prod and dev. Everything is working fine, however I don't understand what is actually happening in the background. I have created a diagram to illustrate my setup.
My communication setup (app->server->google):
Both versions have the same GCM sender (created in the same google project) and different google api keys (each app has its own applicationID). A server is responsible for the communication between the users of each app version. An app sends the server the user's regID and message. The server then forwards this request and the google api key 1 of prod to google. Google then sends the corresponding push notifications.
This setup is working for both app versions prod and dev. I tried to switch the google api key (1/prod) of the server to the other one (2/dev) in case the dev app is communicating with the server. As a result no messages could be sent anymore.
Can somebody help me understand what is actually happening?
My theory is that google registers the regIDs with the initially sent google api key.

Related

Browser key in old Google Cloud Messaging app no longer working

I have been using Google Cloud Messaging to send messages to my phone via php pages on my permanently on server (a Raspberry Pi) successfully for some time. In that old app I used a browser key with no restrictions and not a server key.
I was aware that GCM should be migrated to Firebase Cloud Messaging (FCM) and have successfully done this. During development both FCM and GCM apps were working. Recently my GCM app returns Unauthorized (401) errors to my server. I know that FCM will only give out restricted server keys now and that unrestricted keys are not issued.
I am surprised that my old app developed before FCM even existed has stopped working. I assume that the message sent from my server to Google is being rejected by them.
Am I correct in my assumption that old GCM browser keys will always be rejected by Google?
Am I correct in my assumption that old GCM browser keys will always be rejected by Google?
Yes. As of right now, GCM and FCM will only accept Server Keys.
Using any other type of API Keys (Android, iOS, Browser) will result in a 401 error. One example of this is this post, the OP originally had an Android Key and it started to return a 401 error.

online notification in android

I've built an Android application by android studio.
I want to be associated with users online and notify changes and news.even when my application is closed.
This is what is on my mind,I have web server, i want create a internet connection listener and when connection is available,application or a part of it connect with the server and get new information and notify the user with a notification.even when my application is closed.
How can I implement and enforce it?
Try "Google Cloud Messaging."
Per their Developer Console Help page: "Google Cloud Messaging (GCM) is a free service that helps developers send messages across multiple platforms: Android, iOS, and Chrome. For example, a server can send messages directly to single devices, groups of devices, or devices subscribed to topics. Also, the application on a device can send messages directly to a server and to devices belonging to the same group."
Use the Google Cloud Messaging service alongside the Google Plugin for Eclipse. Google Cloud Platform explains as: "When targeting Android devices, it is easy to get started by using Google Plugin for Eclipse (GPE). GPE allows you to generate an App Engine Connected Android Project that provides the basic logic needed for sending push notifications using Google Cloud Messaging for Android from a mobile backend running on Google App Engine."
This could send messages for you without having to do the work on your own server. If this answer helped you, please consider up-voting or accepting it as the answer. Thanks, and best of luck on your project!
No,These systems are always some limitations and managed with others.I do not need to communicate with iOS or chrome ,I need to design a system that's all for me.Experience has shown me great services, such as Google services and any other company affected by political issues.for example i live in iran right now.
All production-oriented and knowledge-based services for this country is banned.
due to this problems i prefer to have my own messaging and notification system.

IS GCM A CLOUD ENDPOINT OR SEPARATE ENTITY?

I am new to android development,I am working on push notification app now and trying to get overview of concepts about GCM and got stuck with one of the concept about use of "endpoint".
I am going through below google developer link:
https://developers.google.com/eclipse/docs/endpoints-addgcm
they have given something like this
Google Cloud Messaging (GCM)allows your Cloud Endpoints to send
notifications to registered Android devices whenever the state of a
resource changes. For example, suppose a user uses a Note application
from 2 devices: Device A and Device B. If the user is adding a note
from Device A. Google Cloud Messaging can be used in the Cloud
Endpoint for the insert operation to ping Device B to indicate that a
note has been added.
my questions are
1>> Is GCM itself an endpoint?or it is a separate entity?
2>> how to interact with 3rd party app server without using endpoint for server and client?
Thanks in Advance!
GCM and Cloud Endpoints are separate and unrelated Google services (though one possible source of confusion is that the term 'endpoint' is often also used in more generic ways).
Endpoints is a service for creating public API's for GAE app's. It can make it easier to create the API's that will allow your clients to communicate with your GAE app, particularly if those clients are iOS, Android, or Web apps (the supported client types), and if you want to use OAuth2 authentication for the apps or their users.
GCM is for waking up, and pushing data to, your apps on those same platforms. It is true that your server app will probably use both GCM and Endpoints, they are separate and unrelated.

Is Google Cloud Messaging from Android to Android possible?

I read about Google Cloud Messaging at http://developer.android.com/google/gcm/gcm.html.
It supports Third Party Application server to Android application push notification.
I am wondering whether it is possible to implement the same thing push/receive notification from an Android app on one mobile to the same Android app on another mobile using Google Cloud Messaging.
If not, is there any other free service available similar to Google Cloud Messaging?
An Android device can send a GCM message to another Android device. All it needs is the API Key (of the Google API Project ID that the app uses to register to GCM) an the Registration ID of the other device. Using these parameters it can send a GCM message to another device via an HTTP request.
Usually applications that use GCM require a 3rd party server in order to store the Registration IDs of all registered devices. If your app has a different way to let devices share their Registration IDs with each other without requiring a server, you don't need the server.
As far as I'm aware, there has to be a server in the middle to send the push notifications (Android -> Personal Server -> GCM Server -> Android)
So the Android device sending the notification would send some data to a script on the server (using a HTTP GET/POST), and that script would then send the push notifications to all the devices that you wanted it to
Following the example Code from google (GCM Client Example), you can build an app to get a registration ID for your device, but sending messages without a server wouldn't work in my opinion. I didn't tried by now, but what about using the Google Backend Starter, or (what I tried) using a Backend as a Service Provider like apiOmat if you can't afford or don't want to set up a server.

Android Messages - Development vs Distribution

Forgive me for not knowing the correct Android termonology. I come from an iOS background so I'm trying to learn how to do two things correctly in the Android world.
Control "Badges" for Android
Send "Push Notifications" via Distribution (production) vs Development.
Fortunately I found the answer to #1 which is to use Status Bar Notifications thanks to this question.
Now for #2. I already have a GCM setup and can send notifications out to all registered devices. However, sometimes I want to be able to send notifications to all user's phones, and sometimes only to "development" devices. With iOS this is distinguished by devices that have been downloaded from the App Store / Ad-Hoc environment (Distribution) and devices that have been physically plugged into a computer which complies the source onto their device (Development). Is there anything similar to this for Android?
There is no difference between development and distribution in Google Cloud Messaging. All the messages are sent from your server to the same GCM endpoint.
If you want to distinguish between development devices and non-development devices, you'll have to manage it on your server's DB (for each registration ID you store in your server, add a flag that says if it's a development device or not).
EDIT :
Actually there's something else you can do, though I'm not sure it's such a good idea. When the app registers to GCM, it supplies a sender ID (which is a Google API project ID). You can use two different project IDs for development release and production release. The registration IDs returned by the registration process are tied to the project ID. Now, when you send a GCM message from your server, you send it using an API key that is tied to a project ID. If you use the API key that is tied to your development project ID, only registration IDs which are tied to that project ID (i.e. they originated from devices that have the development build) will work. Sending messages with "production" registration IDs will result in MismatchSenderId error (which is similar to APNS in the way that sandbox device tokens are invalid in the production environment and vice versa). I'm not sure that's a good idea, because you don't want to rely on errors from Google for your logic. If you want to send messages only to a subset of your clients, you should manage this subset in your DB.

Categories

Resources