Enable Cloud Messaging API
To enable the legacy Cloud Messaging API, take the following steps.
Enable Firebase's Cloud Messaging
Step 1 Open Firebase console
In Firebase console, go to Project settings > Cloud Messaging and select Manage API in Google Cloud Console to open Google Cloud Console.
Step 2 Go to API Library
Go to API Library using the back button as shown below.
Step 3 Find Cloud Messaging API
In the search bar, enter "cloud messaging".
In the search results, select Cloud Messaging as shown below.
Step 4 Enable Cloud Messaging API
Click Enable to start using the Cloud Messaging API.
Step 5 Check that the legacy API has been enabled
If you go back to your Firebase console, the Cloud Messaging API should be enabled with a newly generated server key.