Android GCM SENDER_ID, how to get it? - android

I try to migrate to GCM and I have an issue with the SENDER_ID I need to provide. I use the demo project from google. In this project I need, if I understand this well, to provide a SENDER_ID to the application in the CommonUtilities.java file.
The SENDER_ID I provided is the API key I registered on https://code.google.com/apis/console/ and has this form: AIzaSyAxxxxxxx_xxxxxxxxxxxnoGZw (total 40 chars).
Using this string as SENDER_ID I get on "BroadcastReceiver mHandleMessageReceiver" an error message: From GCM: error (INVALID_SENDER)..
Where is the mistake? The string I provide is not the SENDER_ID?
Thank you.

No, the SENDER_ID is the project ID you signed up at Google API console, it should a numeric string. e.g. on your browser URI, you should see this:
https://code.google.com/apis/console/#project:4815162342
The Sender ID is 4815162342
Updated Answer:
Google has not updated its docs completely. The above answer is old and its based on this documentation and it seems that its still not updated.
According to updated Google docs, it seems that Project Number on Google API Console is used as SENDER ID

I have done for Latest Google API Console.
How to get SenderId:
Steps:
Open Google api console
Create project
Click on Left hand side menu icon
Click on Google cloud Platform
You would get SenderId form there
Reference:
Hope this will help you.

Go to your Google APIs Console page. Select the project you use from the drop down menu on the left. Select Overview and now you can see you project number. It is the SENDER_ID you have to use
Another way to get your project number is to get the value of "project" from your url. Your url has to be like this: "https://code.google.com/apis/console/b/0/#project:886025556782". Here the project number is "886025556782". this number is SENDER_ID

An updated answer as of Nov 2014 IF YOU'VE CREATED AN API PROJECT RECENTLY.
First of all, correct, you should absolutely go to the Google Developers Console and find the Project that you have GCM enabled on. When looking at the Overview section (left-hand nav panel), you'll see Project ID and Project Number listed on the right hand side. Project ID was failing for me (which is what led me here), but when I tried the Project Number, I'm able to register my clients correctly now.
Note that this is different because Google modified how they assign project IDs recently. In October I made a project and was given an all numerical Project ID, which I assume would work fine. But the one I created today was given a two-word and a number id (like Hamster-Party-420) and a numeric Project Number. The URL to my project contains Hamster-Party-420, and the Project Number is only visible on the Overview screen.

Yet another updated answer with little more explanation for the confused(..like I was).(with due credit to #azgolfer, #PankajAndroid and #Adam)
1- If you create a project at https://console.developers.google.com, you can see two things "PROJECT ID" and "PROJECT NUMBER" in project overview. Project Id is no longer numeric but alpha numeric like master-xxxxx-1234. Project number is a 11 digit number like 123456789100.
2- Even when you inspect the browser link you can find it as:
https://console.developers.google.com/project/master-xxxxx-1234
So is master-xxxxx-1234 is the SENDER_ID (at some places referred as PROJECT ID)? NO.
You have to use the project number as project id in GCM.
3- Where can you cross check that project id is being used as project id?
On API Dashbaord. (url: https://code.google.com/apis/console/b/0/?noredirect#project:12345678900 - where 12345678900 is your project number on project dashboard.
SUMMARY: Project Id in Project Dashboard and API Dashboard are different. The project number in project dashbaord is used as project id in API Dashboard and Project Id in project dashbaord as Project name in API Dashboard. So the project number shown in the Project Dashboard when we create project in developer console is used as SENDER_ID in GCM.

Go to "Dashboard" in the latest version of the developers console, click the drop down arrow under "Project: Turtle Power" and you can see the Project number right there! Use that as your SENDER_ID
(fake project so don't even try it =P)

Maybe you haven't activated Google Cloud Messaging for Android in API COnsole.
Here is the instructions:
http://developer.android.com/google/gcm/gs.html

We spent hours trying to figure this out. The problem was that our android manifest did not include the sender id!

If you came here because you are doing web push, Android push, or the like, there is a different answer.
Source: https://firebase.google.com/docs/cloud-messaging/js/client

the SENDER_ID you are using is nothing but the authorization key.
you can find the SENDER_ID at your projects Google APIs Console pages URL
https://code.google.com/apis/console/#project:8543162367
here 8543162367 will be your SENDER_ID ,
and also the Project Id is no longer numeric its alpha-numeric or only numeric or only alphabetic anything but its position is same as shown by me

Related

Leaked GCP API Keys : Your app contains exposed Google Cloud Platform (GCP) API keys. Please see this Google Help Center article for details

I am getting this error from Play Store:
I tried to limit the access of API key within that file but still getting this error. How can I solve this?
Make sure that keys are not leaked via sites such as GitHub.
Notice the message wording "Your app contains exposed ...". That message did not say your app is exposing the keys.
You will need to delete the key and create a new key, update your app, etc.
Delete current key and create new one. Also make sure you apply restrictions like HTTP referrers, IP Address restrictions etc. based on your use case. For more info, check this
https://cloud.google.com/docs/authentication/api-keys#api_key_restrictions
The error is due to the API key being included in your source code. Consider using Google's Secrets Gradle Plugin for Android to hide your API keys from source code. Documentation at https://github.com/google/secrets-gradle-plugin and demo by the author at https://youtu.be/X8lYNW_Or2o

Firebase console - problem receiving test push FCM notification in android device

I am sending push notification using firebase console and i am getting "0% of potential users are eligible for this campaign: 0". and push notification is not displaying in mobile..If anyone got same experience and solve issue then please suggest me how can i solve this issue. I followed all the thing..that i added json file that i got from firebase.
Please check for the following:
Have you configured your android package name correctly.
Did you place the google-services.json file in android/src folder.
Make sure you have done all steps present in this link (If you using android studio i suggest going with option 2)
Get user token to send firebase message Follow the steps
After all these if you still can't receive push notifications try setting channelid in advanced messaging options
Refer https://firebase.google.com/docs/cloud-messaging/android/client link step by step and you will be good to go for your push notification using fcm and if you already implemented the basic things then compare your code with the sample code step by step mentions on the link. you must find out the error. let me know if it resolves your issue.
Go to Build --> clean project -->Rebuild project
(Build is at top in android studio)
Why it was not working - You must have had deleted google-services.json file and re-added it.
Make sure you have only one firebase project configured for this app (if no then delete one you dont plan to use)
Go to firebase setiings -> Left top angle -> settings icon -> Project settings ->
scroll to bottom, then make sure to add SHA certificate fingerprints Type. How to get it
Then (still on this page) press See SDK instructions button. And place google-services.json file in your project.
If all this steps passed for you and you still getting this error then just wait a little bit, for me it take 2 days, before it started working.

aws S3 Transfer Manager Demo shut down

I am trying to run the AWS android samples from https://github.com/awslabs/aws-sdk-android-samples
I have included the following jars in libs:
aws-android-sdk-2.0.4-cognito.jar
aws-android-sdk-2.0.4-core.jar
aws-android-sdk-2.0.4-s3.jar
Also I have added the AWS_ACCOUNT_ID, COGNITO_POOL_ID, COGNITO_ROLE_UNAUTH, BUCKET_NAME
this is the logcat
When im runnig this sample, action and then program shuts down.
What is problem?
I don't know what to do.
The stacktrace shows accountId is malformed. The accountId isn't your login email of your AWS account. Instead, it should be a 12 digit account number. One way to find it is to go to console -> My Account (top right corner).
PS: consider use the latest SDK version v2.2.2. It has lots of improvements compared to v2.0.4. You can find it at http://aws.amazon.com/mobile/sdk/.

GoogleJsonResponseException : 404 not found / 401 Unauthorized in settings google apps endpoint engine backend in android Google Cloud Save

Hello friends i starting learn about google cloud save, so i create apps and follows step given in google.developer and i am also using their example using link https://github.com/GoogleCloudPlatform/solutions-mobile-backend-starter-android-client
and https://developers.google.com/cloud/samples/mbs/android/ but i think i face some problem in autentication, and got error com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
and some time : com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unautorized
i just want to store my game score using google cloud save.please any one can give me solution about it or any related links ? thanks in advance.
I find my own solution :
I follow following step :
hope these help you if necessary :
Assume you are created project on https://console.developers.google.com/
and follow necessary step
like
In API & AUTH -->APIs
Google cloud Storage and Google cloud Messaging for android and whatever you need On
In API & AUTH -->Credentials
Create new Client ID
for
-->Client ID for Android Application and
-->Client ID for Web Application
-->Key for server applications
(1) Open the Google API Console and make sure your Mobile Backend project is the active project by selecting it in the projects pulldown menu in the top left.
(2) Click Services.
(3) Locate Google Cloud Messaging for Android in the list of available services, and click the ON toggle.
(4) Accept the Terms of Services if you have not already.
(5) Click API Access in the top left of the API console.
(6) Scroll down to click Create new Server key... You don't need to supply any IP values in this form. (Using a server key allows you to whitelist IP addresses).
(7) Click Create.
(8) Locate the API key within the Key for server apps form and copy this key to the clipboard.
(9) Navigate to .appspot.com. This will bring you to your Mobile Backend Starter settings configuration page.
(If not find then find from : click on your created project from the https://console.developers.google.com/ click on your created project Monitoring-->overview-->find Mobile Backend Starter from the bottom- of the screen click on that )
(10) Follow all three step of Deployment steps:
-->Deploy the backend
-->Open (for development use only) the backend to accept incoming requests via Settings
click on Settings-->Mobile Backend settings-->
---> Radio button on of **Secured by Client IDs (Recommended)**
---> Enter **Android Client Id, and Web Client id**
---> Google Cloud Messaging and iOS Push Notification **Enabled**
--->**Save**
-->download Sample Project if necessary
In sample project open Const.java file
Enter project_id,
Project_number,
Web_client_id(enter client_id_for_web_application here )
public static final boolean IS_AUTH_ENABLED = **true**;
public static final boolean LOCAL_ANDROID_RUN = **true**;
public static final String ENDPOINT_ROOT_URL = "https://" + PROJECT_ID
+ ".appspot.com/_ah/api/";
If Necessary go to :
App Engine Console -> Main -> Versions. ( https://appengine.google.com/ )
select your project
There you will see a list of versions with a Make Default button below. Select the radio button for the latest version and press the make default button, wait a minute or so, and try your call again.
Note that even if you have only one version that is already set as the default this solution should still work.
You may have to do this again the next time you deploy to app engine.
Hope my above step helping to anyone.
Faced this error when I had not deployed the latest version of backend to the google app engine. HTH

Getting INVALID_SENDER on one device while its working with another GCM android

I am following Android Push Notifications using Google Cloud Messaging (GCM) to implement GCM with my application it was working fine on single device (Galaxy S) when i tried to test it with another device( Galaxy Tab 7') its generating error.
handleRegistration: registrationId = null, error = INVALID_SENDER, unregistered = null
here is the Log which i am getting
V/GCMRegistrar(5649): Registering app my_maypackage of senders APA91bHvzZbO_nyYvaA_QRGDaV-wRAYKjt0qJSQmzPUi2unqG7j0OGuyhVY1A3zh-ZfnA0XT0ffgyKypVJ_5owLZvZBNGARpTBkBg9ED8gVVCDejaIpShghq_tXGhMnFQEufwdCL1ibm
V/GCMRegistrar(5649): Setting registeredOnServer status as true until 2013-04-02 11:02:07.847
V/GCMBroadcastReceiver(5649): onReceive: com.google.android.c2dm.intent.REGISTRATION
V/GCMBroadcastReceiver(5649): GCM IntentService class: my_maypackage.GCMIntentService
V/GCMBaseIntentService(5649): Acquiring wakelock
V/GCMBaseIntentService(5649): Intent service name: GCMIntentService-980172650021-7
D/GCMBaseIntentService(5649): handleRegistration: registrationId = null, error = INVALID_SENDER, unregistered = null
D/GCMBaseIntentService(5649): Registration error: INVALID_SENDER
I/GCMIntentService(5649): Received error: INVALID_SENDER
V/GCMBaseIntentService(5649): Releasing wakelock
Note: both devices are configured with same gmail account.
Log is showing incorrect sender ID. it should be taken from Google api project url. e.g
https://code.google.com/apis/console/b/0/#project:65464654646546
then 65464654646546 is sender ID.
For me what did it was enabling the "Google Cloud Messaging for Android" from the Console's API section:
[Adding to #spanjeta's answer:]
The problem is that it’s not trivial to get the project number, due to Google ever going modifications of the developer console. While Google was kind enough to give developers the possibility to declare a friendly/textual id for their projects, they didn't update the GCM documentation in that this cannot replace project ID in a GCM client.
When you do that (give the project a textual name/ID ) - you cannot use it, because you will get an INVALID_SENDER error.
You must get the pure numerical project ID somehow.
So how do you get the project number? You need to get somehow to the old developer console.
The following way works (for now):
Yo go to The developer console → Your Project → APIS → Google Cloud Messaging for Android → Quota
Then a new, old google devloper console tab will be opened with the following URL:
https://code.google.com/apis/console/b/0/?noredirect#project:YOUR_PROJECT_NUMBER:quotas
Then, use YOUR_PROJECT_NUMBER as the GCM SENDER_ID in your app.
I just wanted to share with you that I ran into this same problem just now.
GCM push worked perfectly fine before, nothing's got changed, and all of the sudden our users flushed back with complaints about not getting push notifications.
So I did check out all the StackOverflow thread re. this issue and still couldn't figure things out (had the app id / keys all correctly input, code's perfectly fine, even tried out on the Google demo and blah blah blah)
So in an act of desperate I went to the dev console and disabled GCM, then re-enabled it... everything just worked!
There is a project ID and the Project Number shown on the top of the Project Dashboard.
Project ID: aaaa-bbb-000000 Project Number: 00000111112
You have to use the numeric Project Number as SENDER_ID.
maybe you need change the GOOGLE_PROJ_ID
First
Second
Good Luck!!

Categories

Resources