You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- You need to do this step if you want to send notifications to the user who has not logged in yet.
193
-
You will have to use Firebase topics to send notifications which is described in detail in the More section.
193
+
You will have to use Firebase topics to send notifications which is described in detail in the Sending Messages section.
194
194
195
195
- Now you can use the following method to initialize Raven before login.
196
196
@@ -240,7 +240,53 @@ useEffect(() => {
240
240
}, []);
241
241
```
242
242
243
-
##
243
+
## Sending messages
244
+
245
+
Follow the [Sending Push](/push/sending-push) doc to setup Firebase and create an event on the Raven console. Once done you can use Raven API to send push notifications.
246
+
247
+
### 1. Sending 1:1 to a user
248
+
249
+
To send a notification directly to a user you can pass either the registered fcm_tokens of the user or just pass the userId. Sending to userId will work if you are using Raven to manage the Firebase tokens.
250
+
In this case, Raven SDK takes care of managing tokens and will send the notification to all the tokens registered for the userId.
251
+
252
+
```bash
253
+
curl --location --request POST 'https://api.ravenapp.dev/v1/apps/{APP_ID}/events/send' \
254
+
--header 'Authorization: AuthKey {API_KEY}' \
255
+
--header 'Content-Type: application/json' \
256
+
--data-raw '{
257
+
"event" : {EVENT_NAME},
258
+
"user": {
259
+
"fcm_tokens": [{LIST_OF_TOKENS}]
260
+
"user_id": {USER_ID}
261
+
}
262
+
}'
263
+
```
264
+
265
+
### 2. Sending to a group of users
266
+
267
+
To send to a group of users, you can use Firebase Topics. In this case, you will have to register the user to a topic using Raven SDK. The SDK has two methods:
You can pass the list of topics to subscribe a user. Note that this can be done only once you have initialized Firebase, retrieved the Firebase token and initialized Raven.
277
+
Once subscribed you can pass the fcm_topic in the Raven API -
278
+
279
+
```bash
280
+
curl --location --request POST 'https://api.ravenapp.dev/v1/apps/{APP_ID}/events/send' \
281
+
--header 'Authorization: AuthKey {API_KEY}' \
282
+
--header 'Content-Type: application/json' \
283
+
--data-raw '{
284
+
"event" : {EVENT_NAME},
285
+
"user": {
286
+
"fcm_topic": {TOPIC_NAME}
287
+
}
288
+
}'
289
+
```
244
290
245
291
<Check>
246
292
You are all set! Just fire Raven API and you should see your web push notification 👍 If you are
0 commit comments