@@ -28,7 +28,6 @@ export class Expo {
2828 private httpAgent : Dispatcher | undefined ;
2929 private limitConcurrentRequests : < T > ( thunk : ( ) => Promise < T > ) => Promise < T > ;
3030 private accessToken : string | undefined ;
31- private useFcmV1 : boolean | undefined ;
3231 private retryMinTimeout : number ;
3332
3433 constructor ( options : Partial < ExpoClientOptions > = { } ) {
@@ -38,7 +37,6 @@ export class Expo {
3837 ) ;
3938 this . retryMinTimeout = options . retryMinTimeout ?? requestRetryMinTimeout ;
4039 this . accessToken = options . accessToken ;
41- this . useFcmV1 = options . useFcmV1 ;
4240 }
4341
4442 /**
@@ -66,10 +64,6 @@ export class Expo {
6664 */
6765 async sendPushNotificationsAsync ( messages : ExpoPushMessage [ ] ) : Promise < ExpoPushTicket [ ] > {
6866 const url = new URL ( sendApiUrl ) ;
69- // Only append the useFcmV1 option if the option is set to false
70- if ( this . useFcmV1 === false ) {
71- url . searchParams . append ( 'useFcmV1' , String ( this . useFcmV1 ) ) ;
72- }
7367 const actualMessagesCount = Expo . _getActualMessageCount ( messages ) ;
7468 const data = await this . limitConcurrentRequests ( async ( ) => {
7569 return await promiseRetry (
@@ -202,11 +196,15 @@ export class Expo {
202196 }
203197
204198 private async requestAsync ( url : string , options : RequestOptions ) : Promise < any > {
199+ const json = JSON . stringify ( options . body ) ;
200+ assert ( json != null , `JSON request body must not be null` ) ;
201+
205202 const sdkVersion = require ( '../package.json' ) . version ;
206203 const requestHeaders = new Headers ( {
207204 Accept : 'application/json' ,
208205 'Accept-Encoding' : 'gzip, deflate' ,
209206 'User-Agent' : `expo-server-sdk-node/${ sdkVersion } ` ,
207+ 'Content-Type' : 'application/json' ,
210208 } ) ;
211209 if ( this . accessToken ) {
212210 requestHeaders . set ( 'Authorization' , `Bearer ${ this . accessToken } ` ) ;
@@ -217,17 +215,11 @@ export class Expo {
217215 headers : requestHeaders ,
218216 } ;
219217
220- if ( options . body != null ) {
221- const json = JSON . stringify ( options . body ) ;
222- assert ( json != null , `JSON request body must not be null` ) ;
223- if ( options . shouldCompress ( json ) ) {
224- fetchOptions . body = gzipSync ( Buffer . from ( json ) ) ;
225- requestHeaders . set ( 'Content-Encoding' , 'gzip' ) ;
226- } else {
227- fetchOptions . body = json ;
228- }
229-
230- requestHeaders . set ( 'Content-Type' , 'application/json' ) ;
218+ if ( options . shouldCompress ( json ) ) {
219+ fetchOptions . body = gzipSync ( Buffer . from ( json ) ) ;
220+ requestHeaders . set ( 'Content-Encoding' , 'gzip' ) ;
221+ } else {
222+ fetchOptions . body = json ;
231223 }
232224
233225 if ( this . httpAgent ) {
@@ -340,7 +332,6 @@ export type ExpoClientOptions = {
340332 maxConcurrentRequests : number ;
341333 retryMinTimeout : number ;
342334 accessToken : string ;
343- useFcmV1 : boolean ;
344335} ;
345336
346337export type ExpoPushToken = string ;
@@ -415,7 +406,7 @@ export type ExpoPushReceipt = ExpoPushSuccessReceipt | ExpoPushErrorReceipt;
415406
416407type RequestOptions = {
417408 httpMethod : 'get' | 'post' ;
418- body ? : ExpoPushMessage [ ] | { ids : string [ ] } ;
409+ body : ExpoPushMessage [ ] | { ids : string [ ] } ;
419410 shouldCompress : ( body : string ) => boolean ;
420411} ;
421412
0 commit comments