Generate A Firebase Server Key

Nov 26, 2016  How to create Google Api Key and Google Sender Id to configure push notifications (Cloud Messaging) in Android in 3 steps For Android & IOS Applications 1) W.

Apr 10, 2020 For example, if you're using gcloud, also generate your key using gcloud. To use a key for one method that's been generated using a different method (such as using a REST-generated key with gcloud), you'll need to edit the key to match the appropriate format. How to send Firebase push notification to your Android or iOS client from application server example. I will give you an example of How to send firebase push notification to Android or iOS devices from PHP, Java, C# or using Rest Client. Here is Rest API example which we will use to send notifications to our client application.You can implement this Rest API in your application server. Mar 26, 2020  To generate a private key file for your service account: In the Firebase console, open Settings Service Accounts. Click Generate New Private Key, then confirm by clicking Generate Key. There seems to be missing a guide for Google sign in with flutter, without firebase. Guides for firebase are in abundance, but if for any reason you want to go bare with google sign in, you are on.

Server implementation is optional. Use the Instance ID service if you wantto perform these operations:

  • Get information about app instances.Verify app tokens or get more information about the app instance that created the token.
  • Create relationship maps for app instances. Create relationships between app instances and entities such as FCM or GCM topics.
  • Create registration tokens for APNs tokens. This API lets you bulk importexisting APNs tokens, mapping them to valid registration tokens for FCM or GCM.
  • Manage registration tokens for push subscriptions.For web applicationsimplemented using the Push API, import your existing push subscriptions, mappingthem to valid registration tokens for FCM.

Get information about app instances

To get information about an app instance, call the Instance ID service atthis endpoint, providing the app instance's token as shown:

Parameters

  • Authorization: key=YOUR_API_KEY. Set this parameter in the header.
  • [optional] boolean details: set this query parameter to true to get FCM orGCM topic subscription information (if any) associated with this token. When notspecified, defaults to false.

Results

On success the call returns HTTP status 200 and a JSON object containing:

  • application - package name associated with the token.
  • authorizedEntity - projectId authorized to send to the token.
  • applicationVersion - version of the application.
  • appSigner - sha1 fingerprint for the signature applied to the package.Indicates which party signed the app; for example,Play Store.
  • platform - returns ANDROID, IOS, or CHROME to indicate the deviceplatform to which the token belongs.

If the details flag is set:

  • rel - relations associated with the token. For example, a list of topicsubscriptions.

Example GET request

Example result

Create relationship maps for app instances

The Instance ID API lets you create relationship maps for app instances.For example, you can map a registration token to a Google Cloud Messaging topic,subscribing the app instance to the topic. The API provides methods for creatingsuch relationships both individually, and in bulk.

Create a relation mapping for an app instance

Given a registration token and a supported relationship, you can createa mapping. For example, you can subscribe an app instance to aGoogle Cloud Messaging topic by calling the Instance ID service atthis endpoint, providing the app instance's token as shown:

Parameters

  • Authorization: key=YOUR_API_KEY. Set this parameter in the header.

Results

Server

On success the call returns HTTP status 200.

Example POST request

Example result

Manage relationship maps for multiple app instances

Using the Instance ID service's batch methods, you can perform batchmanagement of app instances. For example, you can perform bulkaddition or removal of app instances to an FCM or GCM topic.To update up to 1000 app instances per API call, call the Instance IDservice at this endpoint, providing the app instance tokens in the JSON body:

Parameters

  • Authorization: key=YOUR_API_KEY. Set this parameter in the header.
  • to : The topic name.
  • registration_tokens : The array of IID tokens for the app instances you want to add or remove.

Results

On success the call returns HTTP status 200. Empty results indicate successfulsubscription for the token. For failed subscriptions, the result contains oneof these error codes:

  • NOT_FOUND — The registration token has been deleted or the app has been uninstalled.
  • INVALID_ARGUMENT — The registration token provided is not valid for the Sender ID.
  • INTERNAL — The backend server failed for unknown reasons. Retry the request.
  • TOO_MANY_TOPICS — Excessive number of topics per app instance.

Example POST request

Example result

Create registration tokens for APNs tokens

Using the Instance ID service's batchImport method, you can bulk importexisting iOS APNs tokens to Google Cloud Messaging or Firebase Cloud Messaging,mapping themto valid registration tokens. Call the Instance ID service atthis endpoint, providing a list of APNs tokens in the JSON body:

The response body contains an array of Instance ID registration tokens readyto be used for sending FCM or GCM messages to the corresponding APNs device token.

Note: The list of APNs tokens in each request cannot exceed 100.

Parameters

  • Authorization: key=YOUR_API_KEY. Set this parameter in the header.
  • application : Bundle id of the app.
  • sandbox : Boolean to indicate sandbox environment (TRUE) or production (FALSE)
  • apns_tokens : The array of APNs tokens for the app instances you want to add or remove. Maximum 100 tokens per request.

Results

On success the call returns HTTP status 200 and a JSON result body. For eachAPNs token provided in the request, the results list includes:

  • The APNs token.
  • Status. Either OK, or an error message describing the failure.
  • For successful results, the registration token that FCM or GCM maps to the APNs token.

Example POST request

Example result

Manage registration tokens for push subscriptions

Using the Instance ID service's Web methods, you can import existingpush subscriptions for Firebase Cloud Messaging. You can also update anddelete them.

When you import a push subscription, you receive a registration token.This token allows you to use FCM features like topic messaging anddevice group messaging to target notifications to your web apps.

Import push subscriptions

You can import push subscriptions using InstanceID's web endpoint:

The request must contain an authorization header set to an OAuth 2.0 access token, a crypto-key header set to your application server key, andthe PushSubscription object in the request body.

Generate A Firebase Server Keyboard

The response body contains a registration token ready to be usedfor sending FCM or GCM messages to the corresponding web app instancewithout having to encrypt the payload.

Code

Upload your VAPID key pair to the console

To import keys, you must have owner-level accessto the Firebase project. Import your existing public and private key inbase64 URL safe encoded form:

  1. Open the Cloud Messaging tab of the Firebase Console Settingspane and scroll to the Web configuration section.
  2. In the Web Push certificates tab, find and select the link text, 'import an existing key pair.'
  3. In the Import a key pair dialog, provide your public and private keys in the corresponding fields and click Import. The console displays the public key string and date added.

Retrieve an OAuth2 token: Use credentials to mint access tokens

In order to create an access token for the request, you'll need to mint the access token and add it to the HTTP request.

To authorize access to FCM, request the scopehttps://www.googleapis.com/auth/firebase.messaging.

Parameters

  • Authorization: Bearer <access_token>. Set this parameter in the header.
  • Crypto-Key: p256ecdsa=APPLICATION_PUBLIC_KEY. Set this parameter in the header.
  • Request body: PushSubscription.toJson(). Pass the push subscription to theHTTP body withoutparsing it. The content matches W3C encoding of PushSubscription.

Response

Generate A Firebase Server Key Finder

On success the call returns HTTP status 200 OK and a JSON result bodycontaining the IID token.

Example POST request

Example result

Update push subscriptions

You can update the push subscription associated with your registration tokenusing the following endpoint:

Parameters

Generate A Firebase Server Key For Windows 10

  • Authorization: Bearer <access_token>. Set this parameter in the header.
  • Crypto-Key: p256ecdsa=APPLICATION_PUBLIC_KEY. Set this parameter in the header.
  • Request body: PushSubscription.toJson(). Pass the push subscription to the HTTP body withoutparsing it. The content matches W3C encoding of PushSubscription.

Results

On success the call returns HTTP status 200 and a registration token. Thismay be the same token you passed in the request, or a new token.

Example POST request

Example result

Delete push subscriptions

A DELETE request removes the push subscription details from FCM database. Youcan still receive messages in your web application using the Push API protocol.

To delete a push subscription, send a DELETE request to:

Example DELETE request

Example result

Firebase message id

Error responses

Calls to the Instance ID server API returnthe following HTTP error codes:

  • HTTP status 400 (Bad request) - request parameters are missing or invalid.Check error messages for detailed information.
  • HTTP status 401 (Unauthorized) - authorization header is invalid.
  • HTTP status 403 (Forbidden) - authorization header doesn't match theauthorizedEntity.
  • HTTP status 404 (Not found) - Invalid HTTP path or IID token not found.Check error messages for detailed information.
  • HTTP status 503 (Service unavailable) - service is unavailable. Retry therequest with exponential backoff.