Skip to content

Commit

Permalink
Merge branch 'expo:main' into delete_node-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
katayama8000 authored Sep 7, 2024
2 parents e82598a + 42351fa commit 8ce4503
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ import { Expo } from 'expo-server-sdk';
// optionally providing an access token if you have enabled push security
let expo = new Expo({
accessToken: process.env.EXPO_ACCESS_TOKEN,
useFcmV1: false // this can be set to true in order to use the FCM v1 API
/*
* @deprecated
* The optional useFcmV1 parameter defaults to true, as FCMv1 is now the default for the Expo push service.
*
* If using FCMv1, the useFcmV1 parameter may be omitted.
* Set this to false to have Expo send to the legacy endpoint.
*
* See https://firebase.google.com/support/faq#deprecated-api-shutdown
* for important information on the legacy endpoint shutdown.
*
* Once the legacy service is fully shut down, the parameter will be removed in a future PR.
*/
useFcmV1: true,
});

// Create the messages that you want to send to clients
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-server-sdk",
"version": "3.10.0",
"version": "3.11.0",
"description": "Server-side library for working with Expo using Node.js",
"main": "build/ExpoClient.js",
"types": "build/ExpoClient.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/ExpoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export class Expo {
*/
async sendPushNotificationsAsync(messages: ExpoPushMessage[]): Promise<ExpoPushTicket[]> {
const url = new URL(sendApiUrl);
if (typeof this.useFcmV1 === 'boolean') {
// Only append the useFcmV1 option if the option is set to false
if (this.useFcmV1 === false) {
url.searchParams.append('useFcmV1', String(this.useFcmV1));
}
const actualMessagesCount = Expo._getActualMessageCount(messages);
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/ExpoClient-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ describe('sending push notification messages', () => {
test('sends requests to the Expo API server with useFcmV1=true', async () => {
const client = new ExpoClient({ useFcmV1: true });
await client.sendPushNotificationsAsync([{ to: 'a' }]);
expect((fetch as any).called(`${sendApiUrl}?useFcmV1=true`)).toBe(true);
// Request should omit useFcmV1 if set to true
expect((fetch as any).called(`${sendApiUrl}`)).toBe(true);
});

test('sends requests to the Expo API server with useFcmV1=false', async () => {
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1117,11 +1117,11 @@ brace-expansion@^2.0.1:
balanced-match "^1.0.0"

braces@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

browserslist@^4.22.2:
version "4.23.0"
Expand Down Expand Up @@ -1931,10 +1931,10 @@ file-entry-cache@^6.0.1:
dependencies:
flat-cache "^3.0.4"

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down

0 comments on commit 8ce4503

Please sign in to comment.