Search code examples
javaandroid-studiogoogle-cloud-messagingapi-key

Two api keys in android project - one auto generated on developer console


I am new to android, and I am trying to make an app that uses google maps api and gcm. When I first created the project I used the api key I got for the maps api. Then I enabled cloud messaging in the same app ( I followed this tutorial step by step ).

When I created the project and added maps api I got the android key (type android) I used in the project. When I enabled messaging (gcm) I got another key - "Server key (auto created by Google Service)", that is a server type key.

My question is should I continue using only the first key, or the second, or is should I add both?


Solution

  • You should use the first key in your application. The server key that you received is used when you are doing push messages through your server application, you would have also got a sender key along with the server key, now this key would be used in your app to authenticate with the gcm infrastructure and receive push notification.