hello to all i want to use google gcm for my app .. but now is not working ..
open this url shows warning me warning ..
http://developer.android.com/google/gcm/demo.html
The information in this document has been superseded by GCM Server and GCM Client. Please use the GoogleCloudMessaging API instead of the GCM client helper library. The GCM server helper library is still valid.
m confused littel bit .... can any one provide me an latest sample code please
thank you
Use this link to set up your gcm id:
https://developer.android.com/google/gcm/gs.html
Related
I'm building a React Native app and want to include push notifications for Android. We currently have the infrastructure for GCM push from our last app. However this time I need to use the JS code to pass the registration id to our push servers. The old app was a native Java app and used:
gcm = GoogleCloudMessaging.getInstance(mActivityContext);
regid = getRegistrationId(mActivityContext);
I have the API key and sender Id but I need to get the regid using over HTTP not using the Java library used there. I have found https://android.googleapis.com/gcm/register but I can't find any docs on how to use it.
The implementation for this can be done in 2 ways:
Do a volley implementation in android code and pass the result you get to the Javascript through the JS bridge.U can pass it in a form of promise to the javascript.Please refer to the following link:
http://facebook.github.io/react-native/releases/next/docs/native-modules-android.html
Use fetch api.U can use body and headers in the fetch method.Please refer to the following link:
http://facebook.github.io/react-native/releases/next/docs/network.html#using-other-networking-libraries
I'm trying to use the sample code available here: https://github.com/ibm-bluemix-mobile-services/bms-samples-android-hellopush
And the first difficulty I found was on configuring the GCM - it seems that somethings changed since it was documented - anyway I guess I got everything configured correctly.
I got the app working and I'm able to register my device, but there is no notification when I try to send it. I'm using both the bluemix dashboard and the swagger to send a message. The response I get is that the message was sent, but I got nothing on the device (a mobile phone, not the emulator).
I checked my Google API dashboard, and there is no activity on the GCM api.
The application ID is: f97eb706-3375-438d-8221-cd7ac0266de1
I was using Postman to test the GCM API (https://android.googleapis.com/gcm/send) and I was getting an "Error 401 Unauthorized". I tried to create a new API Key, but without success.
After reading this: https://stackoverflow.com/a/22453025/6828416
I tried to create a new project on GCM, and it suddenly started to work.
The Docs are currently being updated for GCM, so that will be fixed very soon.
I attempted to recreate your problem and just tested out the sample with Push Notifications with the Android sample here (with the latest version of Android Studio v2.1.3):
Before:
After:
Here is how I edited my code snippets after cloning the sample (mock values):
Code Edit 1 Before:
BMSClient.getInstance().initialize(this, "<APPLICATION_ROUTE>", "<APPLICATION_ID>", BMSClient.REGION_US_SOUTH);
Code Edit 1 After:
BMSClient.getInstance().initialize(this, "http://imfpush.ng.bluemix.net", "dfadsfadsfdsf-2343-2334-8e82-421c02ce847c", BMSClient.REGION_US_SOUTH);
Code Edit 2 Before:
push.initialize(this, "<APPLICATION_ID>", "<CLIENT_SECRET>");
Code Edit 2 After:
push.initialize(this, "dfadsfadsfdsf-2343-2334-8e82-421c02ce847c", "edec64df-34fd-44e3-9d1e-dfsfsdf989899");
I got these values from the Push Notifications service credentials (mock values).
Here is how I set up GCM:
In my Bluemix config, it looks something like this (mock values):
Here's how I got those values from GCM (mock values):
Sender ID:
API Key:
#Paulo For new projects the dashboard is not coming up to enable GCM API in https://console.developers.google.com.
Steps to enable GCM:
Create New Project->create API Key->Enable GCM.
To Enable GCM please Navigate to Dashboard tab and search for Google Cloud Messaging-> Click on GCM and enable the API. Please wait for 5 min to get it activate.
Configure the GCM credentials for Push Notification-> register the device and send notification.
I can't find this question answered (or addressed) anywhere else, so maybe I am just missing something really obvious, but I have followed these official GCM steps to get GCM added to my Android project and have got stuck.
My first issue is that the documentation states...
...copy the Server API key. Before running the app, you'll need to add this as the value of API_KEY in line 31 of GcmSender.java.
...but what/where is GcmSender.java?
And, my main question, how/where do I specify the URL of my application server in my Android project?
NB - I am using Android Studio. I haven't created my application server yet, but will be doing so with a PHP script that uses HTTP messaging.
The first step is creating a new project at Google Developers Console . At this step, for simplicity, you just need to take note of 2 values: Project Number, which will be used as SENDER_ID in a client project; and API server key (created at Credentials), which will be used as API_KEY in a server project.
You can find more at my simple guide at the following questions:
Adding Google Cloud Messagin (GCM) for Android - Registration process
How to implement a GCM Hello World for Android using Android Studio
Hope this helps!
Have just found it.
In the RegistrationIntentService.java file, there is an empty sendRegistrationToServer(String token) method, so the URL of my application server (and the rest) needs to go in there.
I'm trying to make GCM work with my Android application. I have some questions.
In this article in section Step 3: Write Your Application I can't see any Service. How can I start my BroadcastReceiver without a service? Should I start it? In this section there isn't any Service.
In section Writing the Server Code, in the code, there are two strings:
USERNAME = ''
PASSWORD = ''
What values should I use for them?
There is no need for a service. The broadcast receiver is started by Android when a GCM message arrives. In the old implementation there was an intent service that was called by the broadcast receiver, but it's not required anymore.
The user is <your Google API project Id>#gcm.googleapis.com. The password is the API key. However, the code sample you mentioned is for the new XMPP based API. It's simpler to use the HTTP based API which only requires the API key in the headers of the request. The code in the section you mentioned has a link to an HTTP sample.
In the HTTP API you POST an HTTP request the looks like this to https://android.googleapis.com :
Content-Type:application/json
Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA
{
"registration_ids" : ["APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."],
"data" : {
...
},
}
#Tooto : If you look into the article carefully then you will find in the Manifest.xml the entry of the service class.
<service android:name=".MyIntentService" />
For more details on how to set up the GCM in your android app you can refer to this link : http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
So I am trying to sync to google docs, without having to ask the user for his credentials. I use this code to get an auth-token:
AccountManager mgr = AccountManager.get(activity);
authToken = mgr.blockingGetAuthToken(account, DocsService.DOCS_SERVICE, true);
This returns a auth-token that looks well-formated. So on my DocsService I run:
service.setAuthSubToken(authToken);
However, when I try to use the API I just get a AuthenticationException. Any ideas on how to approach this error?
edit: I do have the USE_CREDENTIALS permission.
The problem is that the returned token is a ClientLogin token, not an AuthSub token. An even bigger problem is that the GData Java Client library does not officially support Android. We recently added a note on the home page of the GData Java Client library that for Android we recommend Google API Client Library for Java instead.
Two samples come up mind that would be helpful for you for getting started with Google API Client Library for Java: calendar-v2-atom-android-sample and docs-v3-atom-oauth-sample
Disclosure: I am an owner of both the GData Java Client library and Google API Client Library for Java projects.
You might also want to take a look at Yaniv's Google I/O 2011 Session slides/video for reference on how to access the GData APIs on Android.
http://www.google.com/events/io/2011/sessions/best-practices-for-accessing-google-apis-on-android.html
As Yaniv explained, Gdata Lib doesn't work in Android. I wasted several hour with no result. It looks pretty weird, its Google's product and still not supported in their own platform (Android).
Anyway I have developed a Client Library which works on Android. I am managing the project on Google Code-
http://code.google.com/p/google-spreadsheet-lib-android/
You can give a try.