Cannot get ExpoPushToken on IOS

Please provide the following:
SDK Version - 42:
Workflow - Bare
EAS version - 0.39.0

I have an app build with eas build --profile preview --platform all, and on IOS i cannot seem to retrieve the ExpoPushToken. On Android it works just fine. I tried to fix the issue with removed the APN push key, the Provisioning Profile and the Distribution Certificate, created them again from the EAS prompts, but the problem persists.

The code I’m using for retrieving the Push token is the one from the Expo Documentation.

async function registerForPushNotificationsAsync() {
  let token;
  if (Constants.isDevice) {
    const { status: existingStatus } =
      await Notifications.getPermissionsAsync();
    let finalStatus = existingStatus;
    if (existingStatus !== "granted") {
      const { status } = await Notifications.requestPermissionsAsync();
      finalStatus = status;
    }
    if (finalStatus !== "granted") {
      alert("Failed to get push token for push notification!");
      return;
    }
    token = await Notifications.getExpoPushTokenAsync();
  } else {
    alert("Must use physical device for Push Notifications");
    return;
  }

  if (Platform.OS === "android") {
    Notifications.setNotificationChannelAsync("default", {
      name: "default",
      importance: Notifications.AndroidImportance.MAX,
      vibrationPattern: [0, 250, 250, 250],
      lightColor: "#FF231F7C",
    });
  }

  return token;
}

I’m calling this function inside a useEffect, and sending the token to the server, to store it in the users data, but on IOS the token returned is undefined.

i dont see a branch for

  if (Platform.OS === "ios") {
  }

try adding one in.

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