androidiosreact-nativeexpoexpo-notifications

Expo Notifications: Stopped being able to receive notifications on iOS


I am implementing expo-notifications into my react native app. Notifications have been working fine up until a couple weeks ago and I can't figure out what the issue is.

Everything on Android is working properly, but on iOS I'm not able to receive notifications. I've checked and I have notifications allowed in my settings and am receiving a "valid" ExpoPushToken because I was able to put that push token into their testing tool without error. I also tested it myself on postman using their api and received a status of "ok", but still didn't see a notification on my phone.

Here's my code for getting the token:

    async function registerForPushNotificationsAsync() {
        let token;
        if (Device.isDevice) {
            const { status: existingStatus } =
                await Notifications.getPermissionsAsync();
            let finalStatus = existingStatus;
            if (existingStatus !== "granted") {
                const { status } = await Notifications.requestPermissionsAsync({
                    ios: {
                        allowAlert: true,
                        allowBadge: true,
                        allowSound: true,
                    },
                });
                finalStatus = status;
            }
            if (finalStatus !== "granted") {
                // alert("Failed to get push token for push notification!");
                return;
            }
            token = (
                await Notifications.getExpoPushTokenAsync({
                    experienceId: "@username/app-slug",
                })
            ).data;
            console.log(token);
        }

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

        return token;
    }

Obviously @username and app-slug are my username and slug for my expo project.

The only thing that I know has changed is I've upgraded to Expo SDK 46 and I added in the experienceId into the getExpoPushTokenAsync function. Could adding experienceId screw up receiving notifications? Or is there something obvious that I'm missing here?


Solution

  • I figured out my issue. I had multiple Push Keys that were set up in my Apple Developer account. I revoked both and had expo generate a new one using eas credentials and that fixed my issue.