getting error message for expo push notifications on iOS

Please provide the following:

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

hello, I am trying to get notifications on iOS working. Here is how I am doing it:

import * as Permissions from 'expo-permissions';
import Notifications from 'expo';

async componentDidMount() {

    await Permissions.getAsync(Permissions.NOTIFICATIONS)
    .then((response) =>
        response.status === 'granted'
            ? response
            : Permissions.askAsync(Permissions.NOTIFICATIONS)
    )
    .then(async(response) => {
        if (response.status !== 'granted') {

            this.setState({
                pushStatus: false
            })


            return Promise.reject(new Error('Push notifications permission was rejected'));
        }

        
        const token = (await Notifications.getExpoPushTokenAsync()).data;
        console.log(token);
        return token;
    })
    .then(token => {
        Firebase.firestore().collection('users').doc(Firebase.auth().currentUser.uid).set({
            token: token,
            pushStatus: this.state.pushStatus
        }, { merge: true })
    })
    .catch((error) => {
        console.log('Error while registering device push token', error);
    });
}

But im getting the following error when running on iOS:

 Error while registering device push token [TypeError: undefined is not an object (evaluating '_expo.default.getExpoPushTokenAsync')]

I am running it by scanning the QR code on my iPhone which opens up the expo app and runs the application. When I accept the permission for push notifications, I get the error.

How can I fix this? Thanks in advance

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