# FCM notifications

## Send a notification to one user

`FcmSendToUser` is a public `POST` endpoint. It does not require an
`Authorization` header. Send the recipient and notification fields in the POST
body as JSON:

```bash
curl -X POST https://YOUR_API_HOST/backend/study/admin/FcmSendToUser \
	-H 'Content-Type: application/json' \
	-d '{
		"user_id": 123,
		"title": "Study reminder",
		"message": "Your task is waiting.",
		"logo": "https://mystudyplanner.in/pwa-icon/icon-192x192.png",
		"url": "https://mystudyplanner.in/planner",
		"data": {
			"type": "study_reminder"
		}
	}'
```

The notification is sent to all active FCM tokens registered for that user.
When the notification is clicked, the client opens the supplied `url`.
The POST fields are `user_id`, `title`, `message`, `logo`, `image`, `url`, and
optional `data`. `message` is also accepted as `body`, and `logo` is also
accepted as `icon`. `user_id`, `title`, and `message` are required. Form POST
data is also supported. Tokens rejected by FCM with the `UNREGISTERED` error
code are automatically removed from `fcm_tokens`.