Skip to content

Commit ff6a761

Browse files
Update README.md
1 parent 254b4f5 commit ff6a761

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,24 @@ services.AddSingleton(fcmSettings);
5353

5454
# Firebase Cloud Messages for Android, iOS and Web
5555

56-
For Firebase messages (FCM) we will need a project Server Key and Sender ID. To find Server Key and Sender ID go to Firebase Console (https://console.firebase.google.com), select your project, then go to project settings -> cloud messaging. You should be able to find everything you need there. Here is a simple example of how you send Firebase notification:
56+
To start sending Firebase messages you need to have Google Project ID and JWT Bearer token. Steps to generate JWT bearer token:
57+
1. Enable HTTP v1 API if you haven't done it yet. Go here for instructions: https://console.firebase.google.com/project/[YOUR_GOOGLE_PROJECT_ID e.g. my-project-123456]/settings/cloudmessaging/
58+
2. From that page you can also go to "Manage Service Accounts". Here is the link: https://console.cloud.google.com/iam-admin/serviceaccounts and select your project.
59+
3. Create Service Account with "Firebase Service Management Service Agent" role.
60+
4. Download Service Account JSON file.
61+
5. Use Utils from the tester project to generate JWT bearer token.
62+
63+
Sending messages is very simple so long as you know the format:
5764

5865
```csharp
5966
var fcm = new FirebaseSender(settings, httpClient);
6067
await fcm.SendAsync(payload);
6168
```
69+
Useful links:
70+
- Message formats: https://firebase.google.com/docs/cloud-messaging/concept-options#notifications
71+
- Migrating from legacy API: https://firebase.google.com/docs/cloud-messaging/migrate-v1
72+
73+
## Firebase iOS notifications
6274
If you want to use Firebase to send iOS notifications, please checkout this article: https://firebase.google.com/docs/cloud-messaging/ios/certs.
6375
The library serializes notification object to JSON using Newtonsoft.Json library and sends it to Google cloud. Here is more details on the expected payloads for FCM https://firebase.google.com/docs/cloud-messaging/concept-options#notifications. Please note, we are setting the "to" property to use device token, so you don't have to do it yourself.
6476

0 commit comments

Comments
 (0)