Push on bare workflow: getExpoPushTokenAsync not resolving

Hello,

I have trouble getting expo-notifications working with the bare workflow in a couple of our ejected apps. When troubleshooting I tested the setup with a new and clean project – these are the steps I took:

  1. Created app with npx react-native init MyApp and started it to confirm the basic setup.
  2. Installed Unimodules (https://docs.expo.io/bare/installing-unimodules/)
    a) npm install react-native-unimodules
    b) npx pod-install
    c) Copied the configuration for iOS
  3. Installed expo-notifications (https://docs.expo.io/push-notifications/push-notifications-setup/)
  4. Added slug and ios.bundleIdentifier in app.json under expo property.

After these steps I published the app once (https://github.com/brentvatne/push-notif-example/blob/f3ad8240166c42863c23a4edff40c2cbae521e18/App.tsx#L5-L13) so expo knows of it and added the APN push key with expo credentials:manager. When listing the uploaded key it shows as follows:

Push Notifications Key - Key ID: M9DFYLY3Q6
Apple Team ID: MAMAYY5H8H,  Apple Team Name: entrecode GmbH (Company/Organization)
not used by any apps

I’m not sure why it says not used by any apps. Does anyone had a similar issue and knows how to resolve this? Is this even a problem for bare apps?

Anyways, in my App.js I added:

async function registerForPushNotificationsAsync() {
  let token;
  if (Constants.isDevice) {
    console.log('get push permission');
    const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
    let finalStatus = existingStatus;
    if (existingStatus !== 'granted') {
      console.log(`ask push permission: ${existingStatus}`);
      const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS).catch((err) => {
        console.error(`Error in ask permission: ${err.message}`);
        throw err;
      });
      finalStatus = status;
    }
    if (finalStatus !== 'granted') {
      alert('Failed to get push token for push notification!');
      return;
    }
    // await Notifications.requestPermissionsAsync();
    console.log('getting expo push token');
    token = (
      await Notifications.getExpoPushTokenAsync({
        experienceId,
        development: true,
      }).catch((err) => {
        console.error(`Error in get expo token: ${err.message}`);
        throw err;
      })
    ).data;
    console.log(token);
  } else {
    alert('Must use physical device for Push Notifications');
  }

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

  return token;
}

The problem I’m facing now is in Notifications.getExpoPushTokenAsync() (I tested it with and without the development flag) after granting the push permission on my iOS device it stops after console.log('getting expo push token');. It neither resolves nor rejects. :frowning: The other solutions I found in expo forum didn’t work for me.

If this is important: I’m using a physical device connected via cable and start the app with Xcode.

Has anyone made this happen and can share some details on a successfull integration?

Best,

Simon