Expo SDK 38 - Notifications Error retrieving ExpoToken.

Please provide the following:

  1. SDK Version: 38
  2. Platforms(Android/iOS/web/all): Android && iOS

Unable to retrieve token via Notifications.getExpoPushTokenAsync();

It has been working for the past days/weeks with no issues suddenly starts returning:

[Unhandled promise rejection: Error: Error encountered while fetching Expo token, expected an OK response, received: 400 (body: "{"errors":[{"code":"API_ERROR","message":"\"value\" must be of type object."}]}").]

Using the following code:

async function registerForPushNotificationsAsync() {
  if (Constants.isDevice) {
    const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
    let finalStatus = existingStatus;
    if (existingStatus !== 'granted') {
      const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
      finalStatus = status;
    }
    if (finalStatus !== 'granted') {
      alert('Failed to get push token for push notification!');
      return;
    }
    const token = await Notifications.getExpoPushTokenAsync();
    console.log(token);
  } else {
    alert('Must use physical device for Push Notifications');
  }

  if (Platform.OS === 'android') {
    Notifications.createChannelAndroidAsync('default', {
      name: 'default',
      sound: true,
      priority: 'max',
      vibrate: [0, 250, 250, 250],
    });
  }
}
2 Likes

Thank you for posting! I have been experiencing the same issue.

1 Like

I’m unsure what type of dark coding magic happened but it seems to be working now. @shkurkin is your project working as well?

1 Like

Possibly related (if it was a recent Expo deployment), all of our push notifications are now being rejected. We send stringified JSON in the data key, and that’s now being rejected with the error "[0].data" must be of type object. Changing the type to an object does allow the notification to send, but clients aren’t prepared to receive an object, they try to deserialize the JSON.

Was this an expected update to the Expo API?

@itstrevino the gods have shown mercy! Yes it has just started working for me as well :+1:

1 Like

Hi guys, are you still seeing this issue? Sorry for the late response

If you are, let me know what version of expo-notifications you’re using (or if you’re using the legacy package)

Currently experiencing this issue. Using Expo SDK 38

"expo-notifications": "~0.3.3",