11/**
2- * exponent -server-sdk
2+ * expo -server-sdk
33 *
44 * Use this if you are running Node on your server backend when you are working
55 * with Expo
@@ -24,30 +24,37 @@ const PUSH_NOTIFICATION_CHUNK_LIMIT = 100;
2424// TODO: Eventually we'll want to have developers authenticate. Right now it's
2525// not necessary because push notifications are the only API we have and the
2626// push tokens are secret anyway.
27- export default class ExponentClient {
27+ export default class ExpoClient {
2828 static pushNotificationChunkCapacity = PUSH_NOTIFICATION_CHUNK_LIMIT ;
2929
3030 _httpAgent : ?HttpAgent ;
3131
32- constructor ( options : ExponentClientOptions = { } ) {
32+ constructor ( options : ExpoClientOptions = { } ) {
3333 this . _httpAgent = options . httpAgent ;
3434 }
3535
3636 /**
37- * Returns `true` if the token is an Exponent push token
37+ * Returns `true` if the token is an Expo push token
3838 */
39- static isExponentPushToken ( token : ExponentPushToken ) : boolean {
39+ static isExpoPushToken ( token : ExpoPushToken ) : boolean {
4040 return ( typeof token === 'string' ) &&
4141 token . startsWith ( 'ExponentPushToken[' ) &&
42- token [ token . length - 1 ] === ']' ;
42+ token . endsWith ( ']' ) ;
43+ }
44+
45+ /**
46+ * Legacy alias for isExpoPushToken
47+ */
48+ static isExponentPushToken ( token : ExpoPushToken ) : boolean {
49+ return ExpoClient . isExpoPushToken ( token ) ;
4350 }
4451
4552 /**
4653 * Sends the given message to its recipient via a push notification
4754 */
4855 async sendPushNotificationAsync (
49- message : ExponentPushMessage ,
50- ) : Promise < ExponentPushReceipt > {
56+ message : ExpoPushMessage ,
57+ ) : Promise < ExpoPushReceipt > {
5158 let receipts = await this . sendPushNotificationsAsync ( [ message ] ) ;
5259 invariant ( receipts . length === 1 , `Expected exactly one push receipt` ) ;
5360 return receipts [ 0 ] ;
@@ -63,8 +70,8 @@ export default class ExponentClient {
6370 * messages into appropriately sized chunks.
6471 */
6572 async sendPushNotificationsAsync (
66- messages : ExponentPushMessage [ ] ,
67- ) : Promise < ExponentPushReceipt [ ] > {
73+ messages : ExpoPushMessage [ ] ,
74+ ) : Promise < ExpoPushReceipt [ ] > {
6875 let data = await this . _requestAsync ( `${ BASE_API_URL } /push/send` , {
6976 httpMethod : 'post' ,
7077 body : messages ,
@@ -87,8 +94,8 @@ export default class ExponentClient {
8794 }
8895
8996 chunkPushNotifications (
90- messages : ExponentPushMessage [ ] ,
91- ) : ExponentPushMessage [ ] [ ] {
97+ messages : ExpoPushMessage [ ] ,
98+ ) : ExpoPushMessage [ ] [ ] {
9299 let chunks = [ ] ;
93100 let chunk = [ ] ;
94101 for ( let message of messages ) {
@@ -236,16 +243,16 @@ function _gzipAsync(data: Buffer): Promise<Buffer> {
236243 } ) ;
237244}
238245
239- export type ExponentClientOptions = {
246+ export type ExpoClientOptions = {
240247 httpAgent ?: HttpAgent ,
241248} ;
242249
243250type HttpAgent = Object ;
244251
245- export type ExponentPushToken = string ;
252+ export type ExpoPushToken = string ;
246253
247- export type ExponentPushMessage = {
248- to : ExponentPushToken ,
254+ export type ExpoPushMessage = {
255+ to : ExpoPushToken ,
249256 data ?: Object ,
250257 title ?: string ,
251258 body ?: string ,
@@ -256,12 +263,12 @@ export type ExponentPushMessage = {
256263 badge ?: number ,
257264} ;
258265
259- export type ExponentPushReceipt = {
266+ export type ExpoPushReceipt = {
260267 status : 'ok' | 'error' ,
261268 details ?: {
262269 error ?: 'DeviceNotRegistered' | 'MessageTooBig' | 'MessageRateExceeded' ,
263270 } ,
264- // Internal field used only by developers working on Exponent
271+ // Internal field used only by developers working on Expo
265272 __debug ?: any ,
266273} ;
267274
0 commit comments