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
Copy file name to clipboardExpand all lines: src/pages/docs/push/getting-started/react-native.mdx
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,7 @@ func application(
140
140
```
141
141
</Code>
142
142
143
-
All further code can be added to `App.tsx`.
143
+
Add all further code to `App.tsx`.
144
144
145
145
## Step 1: Set up Ably <aid="step-1"/>
146
146
@@ -317,7 +317,7 @@ async function deactivatePush() {
317
317
318
318
The `transportType` is set to `fcm` on both platforms because `messaging().getToken()` always returns an FCM registration token, even on iOS. Firebase exchanges the APNs device token for an FCM token internally, so Ably communicates with Firebase rather than APNs directly (instead Firebase sends push notifications to iOS devices via APNs).
319
319
320
-
When `activatePush()`is called, it:
320
+
`activatePush()`does the following:
321
321
322
322
1. Requests notification permission from the user.
323
323
2. Obtains the FCM registration token from Firebase.
@@ -326,12 +326,12 @@ When `activatePush()` is called, it:
326
326
After successful activation, `deviceId` contains the unique device ID assigned to this installation.
327
327
328
328
<Asidedata-type='note'>
329
-
On Android, `notifee.requestPermission()`is used instead of React Native's `PermissionsAndroid` because it handles the `POST_NOTIFICATIONS` permission consistently across Android API levels. On iOS, `messaging().requestPermission()` shows the system notification permission dialog — Firebase Messaging calls the native iOS permission APIs internally.
329
+
On Android, use `notifee.requestPermission()` instead of React Native's `PermissionsAndroid` because it handles the `POST_NOTIFICATIONS` permission consistently across Android API levels. On iOS, `messaging().requestPermission()` shows the system notification permission dialog; Firebase Messaging calls the native iOS permission APIs internally.
330
330
</Aside>
331
331
332
332
## Step 3: Subscribe and test push notifications <aid="step-3"/>
333
333
334
-
Background push notifications are handled automatically by the FCM SDK and displayed as system notifications. For foreground handling, use `@notifee/react-native` to display notifications while the app is open.
334
+
The FCM SDK handles background push notifications automatically and displays them as system notifications. For foreground handling, use `@notifee/react-native` to display notifications while the app is open.
335
335
336
336
Add the following foreground notification handler to `App.tsx`:
337
337
@@ -392,8 +392,8 @@ async function unsubscribeFromChannel() {
392
392
```
393
393
</Code>
394
394
395
-
<Aside>
396
-
Sending push notifications using `deviceId` or `clientId` requires the `push-admin` capability for your API key. Use this method for testing purposes. In a production environment, you would typically send push notifications from your backend server (by posting messages with a `push``extras` field to a channel).
395
+
<Asidedata-type='note'>
396
+
Sending push notifications using `deviceId` or `clientId` requires the `push-admin` capability for your API key. Use this method for testing purposes. In production, send push notifications from your backend server by publishing messages with a `push``extras` field to a channel.
397
397
</Aside>
398
398
399
399
Use the Ably CLI to send a test push notification to your client ID:
@@ -421,7 +421,7 @@ To send push notifications via a channel, you first need a UI to subscribe to th
421
421
422
422
## Step 4: Build the UI <aid="step-4"/>
423
423
424
-
Update the `return` statement in `App.tsx` to add buttons that wire up all the push functions:
424
+
Update the `return` statement in `App.tsx` to add buttons that call all the push functions:
If you tap **Unsubscribe from Channel**, you will no longer receive push notifications for that channel. Send the same command again and verify that no notification is received.
508
+
If you tap **Unsubscribe from Channel**, the device no longer receives push notifications for that channel. Send the same command again and verify that no notification is received.
509
509
510
510
You can also send push notifications directly from your app. The next step shows you how.
511
511
512
512
## Step 5: Send push with code <aid="step-5"/>
513
513
514
-
Just as you can send push notifications through the Ably CLI or dashboard, you can also send them directly from your app using `deviceId` (or `clientId`), or channel publishing methods. For channel publishing, you don't need the admin capabilities for your API key.
514
+
You can send push notifications directly from your app using `deviceId`, `clientId`, or channel publishing. Channel publishing does not require the `push-admin` capability.
515
515
516
516
Add the following functions to `App.tsx`:
517
517
@@ -550,7 +550,7 @@ async function sendPushToClient() {
550
550
```
551
551
</Code>
552
552
553
-
Sending to a channel is just publishing a message on a channel with a `push``extras` field:
553
+
To send to a channel, publish a message with a `push``extras` field:
0 commit comments