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)

1 Like

Currently experiencing this issue. Using Expo SDK 38

"expo-notifications": "~0.3.3",

I am using

“expo-notifications”:"~0.3.3"

Please help me. I want to use expo notification services to send my notification. I don’t want to deal with Google Cloud Messaging, FCM, APN. I want a simple solution and Expo SDKVersion 36 was catering it like a boss but I am suffering since after as I have no option but to upgrade to SDKVersion 38 for the API Level 29 issue on google play store.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

is this in a standalone APK, or in the Expo client app from the play store?
I haven’t been able to reproduce this so providing as much info as you can would be helpful