API key for GCM - android

When using the API key generated for my project from Google developer console in the server side to send GCM - Push notifications, i am getting a 'MismatchSenderId' error. I have cross checked the sender ID in my application and the API key also, which is correct.
Also when creating an API key for push notification implementation, should i go for 'Server key' or 'Browser key' or 'Android key' .I have maps implementation also in my project.
I am new to push notification implementation, so kindly excuse if question is too broad.

when creating an API key for push notification implementation, use:
Server Key to send from your server
Browser Key to send from a web app
Android Key to send from an android app.
also the Sender Id, is really the project id.

Related

Google Cloud Messaging tutorial - messages don't send

I'm following Google Cloud messaging tutorial, I'm not exactly understang phrase:
First, make sure your Server key (not the client API key in googleservices.json) is provided as the value of API_KEY in GcmSender.java.
So in order to run this sample, I need to write a server side? I thought that GcmSender.java already emulates server side of the application? Can someone clarify it?
As #MohanadMohie you should instead use FCM.
First, make sure your Server key (not the client API key in googleservices.json) is provided as the value of API_KEY in GcmSender.java
The GcmSender.java does emulate the function for sending a message. This only states that you should make sure that the API key you use is a valid Server Key.
And as per Server Keys go, there is already a note in the GCM docs saying:
Starting from Sept. 2016 new server key can only be created in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.
Plus, in FCM, you'll be able to make use of the Firebase Console to send push notifications.

Android - GCM server key is not working with Urban Airship

I am trying to integrate Urban Airship Push notification service in my android project.I have created a new project in google developer console and created a GCM server key.I added that GCM key in Urban Airship configuration as well,but it fails to send the notification.
The Urban Airship Error Console throws an error like
Received push with invalid authorization on platform GCM error message
I already created a test project in google developer console 2 months back, and having a valid GCM key. If I integrate this key in UA it works fine. But If I create a new server key in same project that is not working.
API key 4 is recently created but it is not working the Server Key created on June 9th works fine. Is this because the key is auto generated? If that is the issue, how do I auto-create the GCM server key?
Recently, I heard that GCM is migrating to Firebase. Do I need to use FCM key instead of GCM?
Seems that Google is no longer authorizing the API Keys created by Google API Console. I had a similar issue with Amazon SNS, and managed to fix it by using the Firebase auto-generated server key.
1 - Login into Google Firebase console, with the same credentials you used for Google API Console.
2 - Create a new project (or import an existing one).
3 - Click on the gear icon and select Project Settings
4 - Select CLOUD MESSAGING tab.
There you will see both the API Server Key and the Project number (which is needed in the application). This API Server key is the one you need to introduce in the Push Provider console (Urban Airship in your case).

Xamarin.Android PushNotification

I'm trying to create a Xamarin android app with GCM push notifications using this plugin:
https://github.com/rdelrosario/xamarin-plugins/tree/master/PushNotification
I followed the instructions in the readme page and changed ANDROID SENDER ID with my google project number (obtained from the google developer console).
I can successfully register the device using the Register function (the OnRegisteredfunction on the CrossPushNotificationListener class is fired and a valid registration token is returned).
To send a notification I used this tool (because i don't have a backend up and running):
http://apns-gcm.bryantan.info/
I filled:
The Device Token field either with the token obtained with the
previous device registration or with "/topics/global"
The Message field with a random message
The Api Key with a Server API Key generated from the google
developer console
The app never reaches the OnMessage and nothing seems to be received.
What am I doing wrong?
Thanks in advance

Is client id or server id needed in android code for gcm notification?

I want to know "if client id or server id is needed in android code for gcm notification?"
Yes you need server id(i.e API Key). you get this server id from google developer console by creating project. Follow these steps to create project on google developer console
and you also need client id to send notifications to the clients who subscribed to Push notifications

How to use generated API key in GCM code android

I want to integrate GCM in android application for which I have registered my application and enabled GCM service on google developer console also created the API key.
Where to put this API key in android code ?
Any help appreciated.
You don't have to use api key in android code.
You have to use this api key at server side to send notifications and use project number in android code to register device for GCM and obtain unique device id for receiving notifications.
STEPS TO USE GCM
Register the Android app with GCM to receive Registration Id “RegId“
Share “RegId” with the server
Send a message from server to GCM using HTTP POST request
You can read step by step implementation of GCM here.

Categories

Resources