Standalone push notifications

Hey! So I’m using Expo’s push notification system, and it works just fine for my app published on the Expo store.

I went ahead and ran exp build:ios, uploaded my .ipa and made it onto the App Store, but push notifications no longer work. I’m using the following code for my backend;

let messages = []

                                    // Get push_tokens for each friendsToNotify
                                    // Send push notifications to each friendsToNotify
                                    for (let friend of friendsToNotify) {
                                        if (friend.online) {
                                            messages.push({
                                                to: friend.push_token,
                                                sound: 'default',
                                                body: result[0].first_name,
                                                data: result[0],
                                                badge: 1
                                            })
                                        }
                                    }

                                    // console.log(messages)

                                    let chunks = expo.chunkPushNotifications(messages);

                                    (async () => {
                                        // Send the chunks to the Expo push notification service. There are
                                        // different strategies you could use. A simple one is to send one chunk at a
                                        // time, which nicely spreads the load out over time:
                                        for (let chunk of chunks) {
                                            try {
                                                let receipts = await expo.sendPushNotificationsAsync(chunk);
                                                console.log(receipts);
                                            } catch (error) {
                                                console.error(error);
                                            }
                                        }
                                    })();

And it even returns me the usual [ { status: 'ok' } ] in my server logs.

The frontend side is perfectly fine for handing push notifications, they come through using the Expo push notification tool - but only to my Expo store app, and not my standalone iOS app.

What should I do to get push notifications working?

1 Like

do you have the app open when you are trying to send push notifications? ios doesn’t show push notifications when the app is in the foreground. that might not be it, but just checking.

It actually turns out that it didn’t update the push token when I switched from the Expo app to the standalone iOS app, :expressionless:

1 Like

Glad you figured it out

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