npm expo-server-sdk 3.0.0
v3.0.0

latest releases: 3.9.0, 3.8.0, 3.7.0...
5 years ago

Version 3.0.0 of the Expo Node SDK comes with support for the new push notification receipts. The README of this repo demonstrates how to use the new API.

Breaking changes

  • TypeScript: The SDK uses TypeScript instead of Flow. We've found the TypeScript ecosystem and software to be more stable and the inference to be almost as powerful as Flow's. In the interest of stability, the SDK is now written in TypeScript and the npm package includes the original TS source.
  • JavaScript Modules: CommonJS-style require() calls, as opposed to JavaScript import statements, must now explicitly import either the default export or the named Expo export. Any of these work:
    • const { Expo } = require('expo-server-sdk');
    • const { default: Expo } = require('expo-server-sdk');
    • import Expo from 'expo-server-sdk';
    • import { Expo } from 'expo-server-sdk';
    • Does not work: const Expo = require('expo-server-sdk');
  • Asynchronous Push Receipts: The sendPushNotificationsAsync method now returns an array of push tickets instead of push receipts. The difference is that tickets specify whether Expo successfully received the notifications, and receipts specify whether Apple or Google did. A push ticket may contain error information (formatted the same as errors in push receipts) or an "id" field with the receipt ID. Sometime later -- usually within a couple minutes but up to half an hour later -- you must retrieve the push receipts with these IDs to learn whether Apple or Google received the notifications. The push receipts will tell you if your push credentials are correctly configured, for example, and also tell you whether you must stop sending notifications to the device that generated that receipt.
  • Removed singular sendPushNotificationAsync: The method sendPushNotificationAsync has been removed because we highly recommend using the batch method, sendPushNotificationsAsync, for efficiency. No fundamental functionality was removed but the SDK no longer provides the less efficient convenience method.

New APIs

  • Expo client instances have a method named getPushNotificationReceiptsAsync() that accepts an array of receipt IDs and returns a promise that resolves to an object whose keys are the receipt IDs and values are the receipts. If there is no receipt for a given ID, either because it hasn't been generated yet or because it was removed after a day for being stale, the receipt ID will be absent fro the object.
  • There is also a new method named chunkPushNotificationReceiptIds() that takes an array of receipt IDs and returns an array of smaller arrays of receipt IDs. This is a convenience method to help you split up your requests for receipts into chunks under the limit imposed by the Expo server.

Don't miss a new expo-server-sdk release

NewReleases is sending notifications on new releases.