https://github.com/pablo/fcm-test
https://github.com/pablo/fcm-test
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/pablo/fcm-test
- Owner: pablo
- Created: 2019-07-05T23:17:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-11-16T12:35:53.000Z (over 3 years ago)
- Last Synced: 2025-01-30T00:29:36.704Z (over 1 year ago)
- Language: Java
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fcm-test
This is a very small and simple to test push notification sending through Google's FCM. It was useful for
me when I needed to test push notifications in a hostile (in terms of networking conditions) remote
environment which I did not have control on.
Feel free to add what you need and send me a pull request. I almost always approve them without
much hesitation (or control). I know this is bad.
It has way more dependencies that I would have liked:
* Google API Client (and all of its dependencies)
* log4j2
* Jackson
* Jackson Databind
If you manage to remove some, I would love to merge your changes since I hate having dependencies I
could have avoided with a couple of lines of code.
## Usage
First of all, copy all JAR dependencies on the same folder the `fcm-test.jar` is.
Then, create a `config.json` file similar to this:
```json
{
"keyFile": "/path/to/your/service-account.json",
"qty": 3,
"doEnumerateMessages": true,
"projectId": "your-project-id",
"message": "This is a TEST MESSAGE from the grave",
"title": "TESTING, TESTING...",
"tokens": [
"list",
"all-the",
"push-notifications",
"tokens you want to send the notification to"
],
"additionalData": null
}
```
Where:
1. `keyFile` is the `service-account.json` file. You get this from the FCM console at Google's site.
2. `qty` is how many messages you want to send.
3. `doEnumerateMessages` indicates if software should append message number to `title` and `message`.
4. `projectId` is the configured project id. You set this in the FCM console at Google's site.
5. `message` is the message you want to send
6. `title` is the title you want to send
7. `tokens` is a JSON array of the push notifications tokens you want the messages sent to.
8. additionalData is a JSON object that will be sent along with the notification
Finally, you just run:
```$ java -jar fcm-test.jar```
If everything is configured as expected, you should get all the notifications on your devices.