Button to enable Push Notifications doesn't seem to work?

I’m using the exact same code as registerForPushNotificationsAsync in here https://docs.expo.io/versions/latest/guides/push-notifications

When someone click on a button, this function is called

  async setPushNotification() {
    try {
      console.log('can see this ')
      const pushToken = await registerForPushNotificationsAsync()
      console.log('cant see this ', pushToken)
    } catch (e) {
      console.log('cant see this ', e)
    } finally {
      console.log('cant see this')

Basically i get the prompt AND i click ALLOW, then nothing happens, i set the state in my finally call, removed for sake of clarity. It doesnt fall into the catch either. It does however log the token if i restart the app.

Tested on Sim and iPhone 7, same result. It used to work. Cant see what i’m doing wrong.

    "expo": "^29.0.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",

//    "sdkVersion": "29.0.0",

i think the await is not resolving. The location one works fine ?

export async function askLocation() {
  const { status } = await Permissions.askAsync(Permissions.LOCATION)
  if (status === 'granted') {
    return Location.getCurrentPositionAsync({ enableHighAccuracy: true })
  } else {
    return null
const location = await askLocation()
console.log('resolves ', location)

returning Promise.resolve doesn’t work either, only solution is to to call registerForPushNotificationsAsync without await which means the subsequent calls fire without having responded to the push notification permission dialogue

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