Skip to content

Commit d9d01d0

Browse files
docs(messaging): Added a Section for Getting FCM Device Tokens (#6387)
* Added a Section for Getting FCM Device Tokens Co-authored-by: Mike Hardy <[email protected]>
1 parent cce5460 commit d9d01d0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/messaging/notifications.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ If it's called too soon (e.g. within a class constructor or global scope), the n
169169

170170
**Quick Tip:** On `Android` you can test receiving remote notifications on the emulator but on `iOS` you will need to use a real device as the iOS simulator does not support receiving remote notifications.
171171

172+
# Getting a Device Token
173+
174+
To send messages to a device, you would need the FCM token for it, which you can get using the `messaging().getToken()` method. An example is available on '[Notifee pages](https://notifee.app/react-native/docs/integrations/fcm)'.
175+
176+
```jsx
177+
await messaging().registerDeviceForRemoteMessages();
178+
const token = await messaging().getToken();
179+
// save the token to the db
180+
```
181+
172182
# Advanced Local Notifications
173183

174184
FCM provides support for displaying basic notifications to users with minimal integration required. If however you require

0 commit comments

Comments
 (0)