Unable to get device token SDK 35 Android

Please provide the following:

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

Hi, I’m developing an android app using expo sdk 35 and I’m having a problem regarding to our app’s push notification.

I just found out that Notifications.getExpoPushTokenAsync() is not returning any token.

    registerForPushNotificationsAsync = async () => {
        if (Constants.isDevice) {
            const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
            let finalStatus = existingStatus;
            if (existingStatus !== 'granted') {
                const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
                finalStatus = status;
            }
            if (finalStatus !== 'granted') {
                alert('Failed to get push token for push notification!');
                return;
            }
            console.log(finalStatus);
            var token = await Notifications.getExpoPushTokenAsync();
            console.log(token);
            this.setState({ expoPushToken: token });
        } else {
        alert('Must use physical device for Push Notifications');
        }
    };

Did you do the firebase setup? I had this problem when updating past version 34. It will only work on a physical phone. you might want to add
if (Constants.isDevice && Constants.appOwnership !== ‘expo’)

instead of just isDevice if using the snack( like me when testing) because it will be a device and so it will hang if it doesnt know that it is not actually loaded on the phone. Atleast that fixed it for me.

no, i didn’t setup firebase and i using expo App from playstore and i add Constants.appOwnership !== ‘expo’ now it show alert must use physical device, thank you very much.

but i’m using phone why the alert still show up ?

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