Skip to content

Commit

Permalink
[notifications][docs] mention try/catch getExpoPushTokenAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzach committed Oct 25, 2021
1 parent 245d54c commit 5d1c97b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
22 changes: 15 additions & 7 deletions docs/pages/versions/unversioned/sdk/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@ Learn how to configure the native projects in the [installation instructions in
{
"expo": {
"plugins": [
["expo-notifications", {
"icon": "./local/assets/notification-icon.png",
"color": "#ffffff",
"sounds": ["./local/assets/notification-sound.wav", "./local/assets/notification-sound-other.wav"],
"mode": "production"
}]
[
"expo-notifications",
{
"icon": "./local/assets/notification-icon.png",
"color": "#ffffff",
"sounds": [
"./local/assets/notification-sound.wav",
"./local/assets/notification-sound-other.wav"
],
"mode": "production"
}
]
]
}
}
Expand Down Expand Up @@ -397,7 +403,9 @@ export interface FirebaseData {

### `getExpoPushTokenAsync(options: ExpoTokenOptions): ExpoPushToken`

Returns an Expo token that can be used to send a push notification to this device using Expo push notifications service. [Read more in the Push Notifications guide](../../../push-notifications/overview.md).
Returns an Expo token that can be used to send a push notification to the device using Expo's push notifications service. [Read more in the Push Notifications guide](../../../push-notifications/overview.md).

This method makes a request to Expo's servers, so it can reject in cases where the request itself fails (like due to the device being offline, experiencing a network timeout, or other HTTPS request failures). To provide offline support to your users, you should `try/catch` this method and implement retry logic to attempt to get the push token later, once the device is back online.

> **Note:** For Expo's backend to be able to send notifications to your app, you will need to provide it with push notification keys. This can be done using `expo-cli` (`expo credentials:manager`). [Read more in the “Upload notifications credentials” guide](../../../push-notifications/push-notifications-setup.md#credentials).
Expand Down
4 changes: 3 additions & 1 deletion docs/pages/versions/v42.0.0/sdk/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ export interface FirebaseData {

### `getExpoPushTokenAsync(options: ExpoTokenOptions): ExpoPushToken`

Returns an Expo token that can be used to send a push notification to this device using Expo push notifications service. [Read more in the Push Notifications guide](../../../push-notifications/overview.md).
Returns an Expo token that can be used to send a push notification to the device using Expo's push notifications service. [Read more in the Push Notifications guide](../../../push-notifications/overview.md).

This method makes a request to Expo's servers, so it can reject in cases where the request itself fails (like due to the device being offline, experiencing a network timeout, or other HTTPS request failures). To provide offline support to your users, you should `try/catch` this method and implement retry logic to attempt to get the push token later, once the device is back online.

> **Note:** For Expo's backend to be able to send notifications to your app, you will need to provide it with push notification keys. This can be done using `expo-cli` (`expo credentials:manager`). [Read more in the “Upload notifications credentials” guide](../../../push-notifications/push-notifications-setup.md#credentials).
Expand Down
22 changes: 15 additions & 7 deletions docs/pages/versions/v43.0.0/sdk/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@ Learn how to configure the native projects in the [installation instructions in
{
"expo": {
"plugins": [
["expo-notifications", {
"icon": "./local/assets/notification-icon.png",
"color": "#ffffff",
"sounds": ["./local/assets/notification-sound.wav", "./local/assets/notification-sound-other.wav"],
"mode": "production"
}]
[
"expo-notifications",
{
"icon": "./local/assets/notification-icon.png",
"color": "#ffffff",
"sounds": [
"./local/assets/notification-sound.wav",
"./local/assets/notification-sound-other.wav"
],
"mode": "production"
}
]
]
}
}
Expand Down Expand Up @@ -397,7 +403,9 @@ export interface FirebaseData {

### `getExpoPushTokenAsync(options: ExpoTokenOptions): ExpoPushToken`

Returns an Expo token that can be used to send a push notification to this device using Expo push notifications service. [Read more in the Push Notifications guide](../../../push-notifications/overview.md).
Returns an Expo token that can be used to send a push notification to the device using Expo's push notifications service. [Read more in the Push Notifications guide](../../../push-notifications/overview.md).

This method makes a request to Expo's servers, so it can reject in cases where the request itself fails (like due to the device being offline, experiencing a network timeout, or other HTTPS request failures). To provide offline support to your users, you should `try/catch` this method and implement retry logic to attempt to get the push token later, once the device is back online.

> **Note:** For Expo's backend to be able to send notifications to your app, you will need to provide it with push notification keys. This can be done using `expo-cli` (`expo credentials:manager`). [Read more in the “Upload notifications credentials” guide](../../../push-notifications/push-notifications-setup.md#credentials).
Expand Down

0 comments on commit 5d1c97b

Please sign in to comment.