Skip to content

Commit d56621c

Browse files
ideexpbot
authored andcommitted
Rename Exponent to Expo in most places
fbshipit-source-id: 32b766c
1 parent 191cd5d commit d56621c

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ yarn add exponent-server-sdk
88
```
99

1010
```js
11-
import Exponent from 'exponent-server-sdk';
11+
import Expo from 'exponent-server-sdk';
1212

1313
// To check if something is a push token
14-
let isPushToken = Exponent.isExponentPushToken(somePushToken);
14+
let isPushToken = Expo.isExponentPushToken(somePushToken);
1515

16-
// Create a new Exponent SDK client
17-
let exponent = new Exponent();
16+
// Create a new Expo SDK client
17+
let expo = new Expo();
1818

1919
// To send push notifications -- note that there is a limit on the number of
20-
// notifications you can send at once, use exponent.chunkPushNotifications()
20+
// notifications you can send at once, use expo.chunkPushNotifications()
2121
(async function() {
2222
try {
23-
let receipts = await exponent.sendPushNotificationsAsync([{
23+
let receipts = await expo.sendPushNotificationsAsync([{
2424
// The push token for the app user to whom you want to send the notification
2525
to: 'ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]',
2626
sound: 'default',

src/ExpoClient.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

243250
type 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

Comments
 (0)