Getting an error when trying to get expo notification token

Please provide the following:

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

I’m getting [TypeError: undefined is not an object (evaluating ‘_PushTokenManager.default.getDevicePushTokenAsync’)] error when it tries to get the user’s expo push token. And I’m also run the app on my Android device. Can anyone help me solve this issue?

import * as Notifications from "expo-notifications";
import * as Permissions from "expo-permissions";

const AppNavigator = () => {
  useEffect(() => {
    registerForPushNotifications();
  }, []);

  const registerForPushNotifications = async () => {
    const permission = await Permissions.askAsync(Permissions.NOTIFICATIONS);
    if (!permission.granted) {
      return;
    }

    const token = await Notifications.getExpoPushTokenAsync();
    expoPushTokensApi.register(token); // sending the token to the server
    console.log(token);
  };

return {}
}

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