Skip to content

Commit

Permalink
Update README.md (#69)
Browse files Browse the repository at this point in the history
Update the example code 
from: 
```ts
 if (ticket.id) {
    receiptIds.push(ticket.id);
  }
```
to 
```ts
 if (ticket.status == "ok") { // doing this help with typescript error
  receiptIds.push(ticket.id)
}
```
The typescript Error: 
```
Property 'id' does not exist on type 'ExpoPushTicket'.
Property 'id' does not exist on type 'ExpoPushErrorReceipt'.
```
this is due to the type being declare like this 
```ts
export type ExpoPushReceiptId = string;

export type ExpoPushSuccessTicket = {
  status: 'ok';
  id: ExpoPushReceiptId;
};

export type ExpoPushErrorTicket = ExpoPushErrorReceipt;

export type ExpoPushTicket = ExpoPushSuccessTicket | ExpoPushErrorTicket;
```
in `src/ExpoClient.ts`
  • Loading branch information
nurbxfit authored May 27, 2024
1 parent 6f93dc1 commit f866215
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let receiptIds = [];
for (let ticket of tickets) {
// NOTE: Not all tickets have IDs; for example, tickets for notifications
// that could not be enqueued will have error information and no receipt ID.
if (ticket.id) {
if (ticket.status === 'ok') {
receiptIds.push(ticket.id);
}
}
Expand Down

0 comments on commit f866215

Please sign in to comment.