Updated Notify_fcm (markdown)

master
Chris Caron 2021-02-23 13:18:13 -05:00
parent 0df3a47979
commit 6ea753087d
1 changed files with 44 additions and 13 deletions

@ -2,41 +2,72 @@
* **Source**: https://firebase.google.com/docs/cloud-messaging
* **Icon Support**: No
* **Message Format**: Text
* **Message Limit**: 160 Characters per message
* **Message Limit**: 5000 Characters per message
### Account Setup
You'll need to create an account with Google's Firebase Cloud Messaging Service (FCM) first to use this.
This plugin uses the **HTTP v1 API** and NOT the **Legacy HTTP API** service. [See here](https://firebase.google.com/docs/cloud-messaging/migrate-v1#update-authorization-of-send-requests).
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 Apprise URL slightly diferent:<br/>
![Firebase](https://user-images.githubusercontent.com/850374/106963460-9dd33600-670e-11eb-8aaa-8499121e3147.png)
### Syntax
Valid syntaxes are as follows:
* **fcm**://**{Project}**@**{APIKey}**/**{Device}**
* **fcm**://**{Project}**@**{APIKey}**/**{Device1}**/**{Device2}**/**{DeviceN}**
* **fcm**://**{Project}**@**{APIKey}**/#**{Topic}**
* **fcm**://**{Project}**@**{APIKey}**/#**{Topic1}**/#**{Topic2}**/#**{TopicN}**
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**://**{Project}**@**{APIKey}**/**{Device1}**/#**{Topic1}**
* `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
| Variable | Required | Description
| --------------- | -------- | -----------
| Project | Yes | The generated _Project ID_ from the FCM Management Console
| APIKey | Yes | The generated _API Key_ from the FCM Management Console
| APIKey | Yes | The generated _API Key_ from the FCM Management Console. This is only required if you intend to use the **Legacy** method.
| Project | Yes | The generated _Project ID_ from the FCM Management Console. This is only required if you intend to use the **OAuth2** method.
| KeyFile | Yes | The location of the _JSON Keyfile__ generated from the FCM Management Console. This is only required if you intend to use the **OAuth2** method.
| Device | No | The device you wish send your message to
| Topic | No | The topic you want to publish your message to.
| mode | No | The mode can be set to either **legacy** or **oauth2**. This is automatically detected depending on what you provide the Apprise 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.
#### Example
Send a FCM notification:
Send a Legacy FCM notification:
```bash
# Assuming our {Project} is Apprise
# Assuming our {APIKey} is bu1dHSdO22pfaaVy
# Assuming our {Device} is ABCD:12345
apprise -vv -t "Test Message Title" -b "Test Message Body" \
fcm://Apprise@bu1dHSdO22pfaaVy/ABCD:12345
fcm://bu1dHSdO22pfaaVy/ABCD:12345
```
Send a OAuth2 FCM notification:
```bash
# Assuming our {Project} is Apprise
# Assuming the path to our JSON {Keyfile} is /etc/apprise/fcm/keyfile.json
# Assuming our {Device} is ABCD:12345
apprise -vv -t "Test Message Title" -b "Test Message Body" \
fcm://Apprise/ABCD:12345/?keyfile=/etc/apprise/fcm/keyfile.json
```