[SOLVED] Not receiving Expo push token in standalone build

Please provide the following:

  1. SDK Version: 40 42
  2. Platforms(Android/iOS/web/all): ios
  3. Add the appropriate “Tag” based on what Expo library you have a question on. ?

[SOLVED] This is working since I moved the registerForPushNotifications function into the parent App.js module. I still don’t know why it worked fine in development. There is still a statey issue I have to deal with in standalone app, but the original problem is solved. It has encouraged me to look at deploying Sentry
[/SOLVED]

[UPDATE]

This still isn’t working but here is what I have tried.

  • I have moved the registerForPushNotifications function to App.js where before it was in a context wrapper. I do now get the popup to ask for permissions to send notifications
  • I added a certificate against the app profile in App Store Connect even though I think this is obsolete?
  • I have moved to EAS build. Which is much smaller builds!
  • I generated a new push key with apple, downloaded it, then uploaded it via expo credentials:manager and choosing to revoke auto generated push keys.
  • I have updated from SDK40 to SDK42 which was painful and my dependencies are shot. I used npm i -force and fixed some imports, and it all seems functional.

Push notifications are flawless on expo go.

[/UPDATE]

Using example code from Expo docs, I am not receiving an expo token like I do in development. I am also not getting any rollbar logs in from standalone app. Not sure if this is because rollbar isn’t compatible or not. Thanks if you can help me.

Notifications.setNotificationHandler({
    handleNotification: async () => ({
        shouldShowAlert: true,
        shouldPlaySound: false,
        shouldSetBadge: false,
    }),
});
const registerForPushNotificationsAsync = async () => {
        if (Constants.isDevice) {
            
            const { status: existingStatus } = await Notifications.getPermissionsAsync();
            rollbar.log(`Existing ${existingStatus}`)
            let finalStatus = existingStatus;
            if (existingStatus !== 'granted') {
                const { status } = await Notifications.requestPermissionsAsync();
                rollbar.log(`Request ${status}`)
                finalStatus = status;
            }
            if (finalStatus !== 'granted') {
                alert('Failed to get push token for push notification!');
                return;
            }
            const token = (await Notifications.getExpoPushTokenAsync()).data;
            rollbar.log(token);
            setExpoPushToken(token)
            
        } else {
            rollbar.log('Must use physical device for push notifications')
            alert('Must use physical device for Push Notifications');
        }

       
    };
registerForPushNotificationsAsync().then(token => {
                setExpoPushToken(token)
                
            }).catch(error => rollbar.error(error))

            // This listener is fired whenever a notification is received while the app is foregrounded
            notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
                setNotification(notification);
            });

            // This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)
            responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
                console.log(response);
            });

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