0% found this document useful (0 votes)
17 views1 page

FCM

The document discusses setting up Firebase Cloud Messaging (FCM) for a project. It describes the necessary files, the process for setting up a Firebase project, how to send notifications from a server by making a POST request, and how to acquire a fresh user token.

Uploaded by

iang thea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

FCM

The document discusses setting up Firebase Cloud Messaging (FCM) for a project. It describes the necessary files, the process for setting up a Firebase project, how to send notifications from a server by making a POST request, and how to acquire a fresh user token.

Uploaded by

iang thea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

# Firebase Cloud Messaging

Find more about FCM implemented in the project and instructions to set-up firebase
for your server.

## Files in use

**FBInstanceIDService**
```
Updates User Token/ID and logs fresh tokens
```

**FBMessagingService**
```
Receives data and builds notifications
```

## Setting up firebase
* Signup for Firebase account
* Add project and fill required information
* Open `Settings > Project settings > Add firebase to your Android app`
* Enter package name you're using currently
* Download config file `google-services.json` and save it to `\app` directory

## Sending notifications from your server


*Create a POST request with headers*
URL `https://fcm.googleapis.com/fcm/send`
content-type: `application/json`
authorization: `key=____your_server_key_here___` (Firebase > Settings > Cloud
Messaging > Server key)

*Required JSON Data*


```
{ "notification": {
"title": "___title_string___",
"text": "___text_string___",
"click_action": "Open_URI"
},
"data": {
"uri": "___the_URL_where_you_want_users_to_send__"
},
"to" : "___user_token___"
}
```

## How to acquire fresh User Token


SWV creates a cookie `FCM_TOKEN` with latest token eveytime app opened that can be
saved to your server.

Token is also saved as Log.d `FCM_TOKEN` for testing.

You might also like