Skip to main content

Firebase Cloud Messaging (FCM)

Account Setup#

You'll need to create an account with Google's Firebase Cloud Messaging Service (FCM) first to use this.

From there you will access the FCM Management Console and choose which mode you wish to leverage when sending your notifications. The modes are legacy and oauth2. Both have their pros and con. Depending on which mode you choose, you will be required to construct your Magic Receipe URL slightly diferent

Receipe#

Valid syntax is as follows:

Legacy Mode#

The legacy mode doesn't seem to suggest it will be decommissioned anytime soon, however this is how the FCM refers to it as. This only requires the APIKey generated through the FCM Management Console.

  • fcm://{APIKey}/{Device}
  • fcm://{APIKey}/{Device1}/{Device2}/{DeviceN}
  • fcm://{APIKey}/#{Topic}
  • fcm://{APIKey}/#{Topic1}/#{Topic2}/#{TopicN}

You can mix and match these entries as well:

  • fcm://{APIKey}/{Device1}/#{Topic1}/

OAuth2 Mode#

The OAuth2 mode is what FCM seems to hint that you use. But it has much more overhead then the legacy way of doing things. It also requires you to point to a specially generated JSON file you can generate from your FCM Management Console.

You can point to the JSON file generated locally (if you saved it onto your PC) or refer to it by it's web URL (if you're sharing it somewhere on your network) like so:

  • fcm://{Project}/{Device}/?keyfile=/path/to/keyfile
  • fcm://{Project}/{Device1}/{Device2}/{DeviceN}/?keyfile=https://user:pass@localhost/web/location
  • fcm://{Project}/#{Topic}/?keyfile=/path/to/keyfile
  • fcm://{Project}/#{Topic1}/#{Topic2}/#{TopicN}/?keyfile=https://user:pass@localhost/web/location

You can mix and match these entries as well:

  • fcm://{Project}/{Device1}/#{Topic1}/?keyfile={JSON_KeyFile}

Parameter Breakdown#

VariableRequiredDescription
APIKeyYesThe generated API Key from the FCM Management Console. This is only required if you intend to use the Legacy method.
ProjectYesThe generated Project ID from the FCM Management Console. This is only required if you intend to use the OAuth2 method.
KeyFileYesThe location of the _JSON Keyfile__ generated from the FCM Management Console. This is only required if you intend to use the OAuth2 method.
DeviceNoThe device you wish send your message to
TopicNoThe topic you want to publish your message to.
modeNoThe mode can be set to either legacy or oauth2. This is automatically detected depending on what you provide the Magic Receipe URL. But you can explicitly set this here if you require.

Note: This notification service does not use the title field; only the body is passed along.