Notifications.getExpoPushTokenAsync() not working on Android (Expo SDK 33)

Hi, I’m developing an android app using expo sdk 33 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. I have followed this in implementing push notifs in our app and everything is right on track when we’re at expo sdk 32, now registerForPushNotifications stops at Notifications.getExpoPushTokenAsync() and returns nothing.

Here is what’s in our code

    registerForPushNotifications = async (existingPushToken = null) => {
    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') {
        return;
    }

    let token = await Notifications.getExpoPushTokenAsync();

    if (token === existingPushToken) {
        return;
    }

    try {
        await fetch(PUSH_ENDPOINT);
    } catch (error) {}
};

Any suggestions or did I miss to read updates about the new sdk version’s push notifs?

Hi @juncahilig- sorry you’re running into this :confused:

What is getExpoPushTokenAsync returning? Is this a standalone app, or in the Expo client?

I have the same issue, I test it with standalone and scanning QR and in emulator, when I do:

console.log('First');
let token = await Notifications.getExpoPushTokenAsync();
console.log('Second');
console.log(token);

It only prints “First” nothing more, I follow the same guide on an existing project

@patofet- you need to be using a physical device to get the push token, and also have appropriate permissions asked for in your app. Go ahead and test this example snack on your device. It should print the push token to the console.

1 Like

yes, it work’s now thanks

1 Like

This is still happening to me. (SDK33)

I am testing the app within Expo Client on android phone.

let token = await Notifications.getExpoPushTokenAsync()

is not returning anything on Android (while works fine for iphone)
(finalStatus value is granted btw)

1 Like

@charliecruzan Having the same experience from before. We’re not receiving any response from Notifications.getExpoPushTokenAsync() on both of our physical & emulator androind phone (Using SDK 33)

The emulator wouldn’t return a push token, you need to be on a physical device.

Could you share your code?

One thing that we do in our code is to put if (Constants.isDevice) {... before the call to Notifications.getExpoPushTokenAsync(), and then do something like an else console.warn('push notifications are only available on physical devices').

This helps avoid some confusion when running on emulators.

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